EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: A patch for libXpm.a (was Re: edm : TwoDProfileMonitorClass : cropping/resizing image)
From: Kate Feng <[email protected]>
To: [email protected]
Date: Thu, 22 Jul 2010 13:12:40 -0400
Hi all,

 I do not know if anyone still use the libXpm.a library
for X11 applications. Since it is used in the 2D video
widget that I mentioned in the previous thread, I attach
the patch here, which fixes the memory leak that happened
on both our Linux RedHat and Debian PCs.  The memory leak
can be detected if the video display is exposed for
some period of time (e.g. not iconized).

I downloaded the source code (ie. xpm-3.4k.tar.gz) for
libXpm.a at ftp://ftp.x.org/contrib/libraries
and applied the attached patch.  If XpmReturnAllocPixels
is not specified in the attributes->valuemask, then
(*freeColors)() should be called.  I hope this helps.

Cheers,
Kate


diff -u create.c.orig create.c
--- create.c.orig 1998-03-19 14:51:00.000000000 -0500
+++ create.c 2010-05-20 09:42:41.000000000 -0400
@@ -929,8 +929,11 @@
if (attributes && (attributes->valuemask & XpmReturnAllocPixels)) {
attributes->alloc_pixels = alloc_pixels;
attributes->nalloc_pixels = nalloc_pixels;
- } else
- XpmFree(alloc_pixels);
+ } else {
+ /* Kate Feng: feeColors() if alloc'ed pixels is not return. Otherwise, memory leaks */
+ (*freeColors)(display, colormap, alloc_pixels, nalloc_pixels, NULL);
+ XpmFree(alloc_pixels);
+ }


/* return created images */
if (image_return)
@@ -2234,8 +2237,11 @@
if (attributes && (attributes->valuemask & XpmReturnAllocPixels)) {
attributes->alloc_pixels = alloc_pixels;
attributes->nalloc_pixels = nalloc_pixels;
- } else
- XpmFree(alloc_pixels);
+ } else {
+ /* Kate Feng: feeColors() if alloc'ed pixels is not return. Otherwise, memory leaks */
+ (*freeColors)(display, colormap, alloc_pixels, nalloc_pixels, NULL);
+ XpmFree(alloc_pixels);
+ }


    /* return created images */
    if (image_return)


Replies:
Re: A patch for libXpm.a (was Re: edm : TwoDProfileMonitorClass : cropping/resizing image) John William Sinclair
References:
Re: edm : TwoDProfileMonitorClass : cropping/resizing image Kate Feng

Navigate by Date:
Prev: RE: Build error. GNU make downgrade? Mark Rivers
Next: copying output of Linux ioc to file Patrick Thomas
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: edm : TwoDProfileMonitorClass : cropping/resizing image Kate Feng
Next: Re: A patch for libXpm.a (was Re: edm : TwoDProfileMonitorClass : cropping/resizing image) John William Sinclair
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·