Experimental Physics and
| |||||||||||||||
|
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)
| ||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |