[Mapserver-dev] [PATCH] mapraster.c - fixing memory leaks

Steve Lime steve.lime at dnr.state.mn.us
Tue Jun 15 19:03:16 EDT 2004


Patch aside, what do folks think about using goto's? They seem a great
help with things like clean-up. However there's not one in the code
presently so I was wondering if there's a bias...

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> "Mladen Turk" <mturk at apache.org> 06/02/04 11:18 AM >>>

Hi all,

Mapraster has a memory leak bug not freeing allocated temporary layer. 
The quickest solution would be to just add the tlptemp variable, but
I've
added standard 'cleanup:' label for function exiting. 

Having something like mpatrol gives:

                Total unfreed bytes:        92899
                Peak memory usage:        1699139
                Largest allocation:        235750
                Smallest allocation:            1
                Total Allocations:            513
                Total Frees:                  505
                Peak Allocations:             385


The patch for mapraster.c gives:

                Total unfreed bytes:           14
                Peak memory usage:        1699139
                Largest allocation:        235750
                Smallest allocation:            1
                Total Allocations:            513
                Total Frees:                  512
                Peak Allocations:             385

So we've save cca 92K of memory on each request.

Here is the patch:
(I can file a bug report if needed)

There is still 14 bytes left hanging but the reason is in the
getString()
from mapfile.c used somewhere :). I'll try to hunt that down.

MT.




More information about the mapserver-dev mailing list