[gdal-dev] Memory leaks?

Simon Perkins s.perkins at l...
Mon Aug 26 15:26:19 EDT 2002


On Mon, 2002-08-26 at 01:15, Paul Selormey wrote:
> > Currently there is no facility to cleanup the driver memory. It is
> intended
> > to live till application shutdown. However, for applications wanting to
> > monitor very closely for memory leaks I can see that this might be
> annoying,
> > so I am willing to add a call to cleanup all the drivers. If you would
> like
> > this, please submit a request into Bugzilla as an enhancement request.
> 
> I think memory leaking should rather be a concern in the library,
> not me! wanting it. Currently, when the application shuts down there is no
> clean up - I do not think this is a normal practice. I will, however, submit
> it
> as an enhancement request, as you requested (have just created the bugzilla
> account).

I don't really see how this is a memory leak. A memory leak is when you
lose all access to a block of allocated memory so that you have no
chance of ever deallocating it. And it's only really a concern if chunks
of memory are repeatedly allocated and then lost. Here, the drivers
consist of allocated chunks of memory that are managed by the GDAL
library, and they are freed up by the OS when the application quits.
This is perfectly standard practice - whenever you run a C/C++ program
there are many blocks of memory that are allocated invisibly in this
way, and that are cleaned up by the OS when the application quits. e.g.
the virtual function tables for each class in C++, and no doubt many
others. To look at it another way, the GDAL library has no idea whether
you are going to need to use a particular driver again until the moment
the application quits, and so it would be an error for the library to
automatically delete drivers any time before the application quits.

Frank was offering to add some user code to free up this allocated
memory in GDAL, if you know that you're going to be short of memory.
This has to be a manual procedure though since only the user can know if
GDAL will no longer be needed. But if you're on this hairy edge then
you're almost certainly not going to have enough memory to actually load
an image anyway, so I don't really see the point...

Cheers,

Sy



-- 
Simon Perkins
Los Alamos National Laboratory, USA
http://nis-www.lanl.gov/~simes






More information about the Gdal-dev mailing list