[MAPSERVER-USERS] Antwort: Re: leaking memory in java mapscript (was Re: thread safety)

rich.fromm nospam420 at yahoo.com
Fri Feb 22 14:53:10 EST 2008



Tamas Szekeres wrote:
> 
> I think this might be the case. Would you try adding something like:
> 

I have the following six testcases:

1) Data from PostGIS, AGG renderer, FORMATOPTION "PALETTE_FORCE=TRUE"
2) Data from PostGIS, AGG renderer, no forcing
3) Data from PostGIS, GD renderer
4) Data from *.shp file, AGG renderer, FORMATOPTION "PALETTE_FORCE=TRUE"
5) Data from *.shp file, AGG renderer, no forcing
6) Data from *.shp file, GD renderer

1, 2, 4, and 5 all leaked.  3 and 6 did not.

In other words, PostGIS vs. *.shp did not matter, PALETTE_FORCE vs. not did
not matter, but AGG (leak) vs. GD (no leak) did matter.

I tried applying the following patch to mapserver 5.0.0:

--- begin ---
--- mapserver-5.0.0-etch/mapgd.c	2007-08-21 11:54:21.000000000 -0700
+++ mapserver-5.0.0-etch-bugfix/mapgd.c	2008-02-22 11:19:41.000000000 -0800
@@ -3696,6 +3696,8 @@
 
       msImageCopyForcePaletteGD(img, gdPImg);
       imgbytes = gdImagePngPtr(gdPImg, size_ptr);
+      if (gdPImg)
+        gdImageDestroy(gdPImg);
     }
     else if ( force_pc256 ) {
       gdImagePtr gdPImg;
@@ -3714,6 +3716,8 @@
       for( i = 0; i < gdPImg->colorsTotal; i++ )
         gdPImg->open[i] = 0;
       imgbytes = gdImagePngPtr(gdPImg, size_ptr);
+      if (gdPImg)
+        gdImageDestroy(gdPImg);
     }
     else
       imgbytes = gdImagePngPtr(img, size_ptr);
--- end ---

Now none of the cases leak.

These have been confirmed both with iterative runs (500 iterations) while
watching memory consumption in top, and with a single run using valgrind.

I will file a bug.

Let me know whether this information is sufficient, or if you want me to
package up a self contained testcase with the cases I used to show the
behavior both before and after the fix.  It will take me a bit of effort to
get everything into a form to package up and file, but it won't be all that
hard, and I'll gladly do it if you'd like.

Thanks very much for your help.

- Rich

-- 
View this message in context: http://www.nabble.com/thread-safety-tp15514019p15641334.html
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list