[Gdal-dev] Re: Memory leak under Matlab (a follow up from -
importFromWkt() problem)
Mateusz Loskot
mateusz at loskot.net
Mon Sep 4 00:06:15 EDT 2006
Joaquim Luis wrote:
>
> Hi, I was following this thread with a particular interest due to
> another problem. I wrote a OGR based Matlab MEX file to do coordinate
> conversions. Well the thing works well but has a small memory leak.
> Though small, the leak is sufficiently important to prevent the use
> of that program when attached to mouse movements (it accumulates
> fast).
Joaquin,
Sounds strange. Is there any chance you're misusing MEX memory
management functions or may be you're following one of MATLAB
buggy examples, like:
http://www.mathworks.com/support/solutions/data/1-1NOXOX.html
May be you're using mexMakeMemoryPersistent in loop or similar call,
so memory is not cleared after your MEX is unloaded.
Note, it's only my surmise.
> Now given the valgrind report about the test prog "importwkt" I
> converted it into a ML mex and, ... the memory leak is still there.
> To be honest a similar story happened with a GMT based mex file to do
> also coordinate conversions, so I'm starting to lean to the
> probability that the problem might be on the Matlab side (a third
> attempt with a OpenCV mex also reveals some memory leak) .
Are you using MATLAB on Windows?
Have you tried to run your MEX with a memory leak checker attached?
If you're using MATLAB on Windows, I'd try to build MEX dll with
VLD leak detector [1] but I'm not sure if it will give you usable
and meaningful report when working with MATLAB.
[1] http://www.codeproject.com/tools/visualleakdetector.asp
Another option is to do some simple tests of memory
allocation/deallocation and observe how MATLAB will behave.
> However, guessing that it wont be nothing at all easy to convince
> Mathworks about this problem I'm asking here about the chances that
> it might be a GDAL memory leak.
IMHO contacting Mathworks support and sending them your MEX code
would be the easiest, but I don't know if effective.
There are chances for memory leaks in GDAL as in every other piece
software. Not much helpful, but thats all I can say.
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Gdal-dev
mailing list