[ka-Map-users] Perl mapscript memory leak?

Steve Lime Steve.Lime at DNR.STATE.MN.US
Wed Jun 28 11:31:39 EDT 2006

When an image goes out of scope Swig should call the destroy method for
each imageObj. If you're feeling bold you could add a debug statement in that
method in mapscript/swiginc/image.i to test for yourself.

How to MapScript and GD.pm interact in your script?


>>> Stephen Woodbridge <woodbri at swoodbridge.com> 6/28/2006 10:16:51 AM >>>
Hi Steve et al,

I ported the ka-map precache2.php to perl and it seems to have a memory 
leak. I'm not sure what is leaking but when I running it, like on the 
1000000, and watch top, you can see the memory grow and it eventually 
fails to on $oMap->draw() command. If I rerun the script and skip the 
already generated tiles, it gets to that same image and works fine then 
memory grows as it writes more tiles and dies again.

Processing scale=1000000, cellSize=0.00317478168804209
   geo dimensions: -160, 15 : -60, 75
   pix dimensions: -50397.16608, 4724.73432 : -18898.93728, 23623.6716
   meta dimensions: -51200, -24320 : -17920, -3840
   meta tiles: 26 x 16 = 416 meta tiles and 10400 tiles
     Group: __base__
Can't call method "save" on an undefined value at ./precache.pl line 352.

There is a chance that this is GD.pm related, but I'm guessing it is 
more likely a problem with perl/mapscript. Neither GD.pm nor mapscript 
have explicit image destroy methods. These are all in narrow scoped 
loops and I have try to explicitly undef the variables but that doesn't 

I'm running a version of mapserver cvs from a few weeks ago. I can 
upgrade to the current cvs, but was reluctant to in the middle of SteveL 
doing GEOS commits yesterday.

This would be a good stress test of the API and I'm willing to provide 
the script.

Any thoughts?

ka-Map-users mailing list
ka-Map-users at lists.maptools.org 

More information about the mapserver-dev mailing list