[postgis-devel] Memory in the Meantime

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Wed Jan 7 14:54:03 PST 2009


Paul Ramsey wrote:

> Sounds like we are developing our 1.5/2.0 roadmap on the sly here, but
> in the meantime, we have a gaping memory leak in the loader in 1.4.
> 
> I see that I can't just change lwfree_pointarray to deep-free, since
> the lwfree_poly and lwfree_line calls in lwgeom will then try to free
> const structures passed to us by PgSQL.
> 
> However, there is a half-thought-out concept of lwrelease_* in
> liblwgeom, which seems to somewhat get there. I would propose that our
> "in the meantime" strategy for this is:
> 
> lwfree_* is a deep free.
> lwrelease_* will free everything down to just above the serialized piece
> 
> I'll fill out *all* the functions for lwrelease_ and then go retrofit
> the existing lwfree_* calls in lwgeom to use lwrelease instead
> (there's actually not that many, because... we are terrible memory
> managers :).
> 
> Comments?

My first thought was that it's a lot of work to go through the code and 
locate all the correct places, but then I realised that you only need to 
look at the code in lwgeom/ which reduces the work by quite a lot.

It's not something I feel strongly enough to run away and fix right now 
(there are only a few places in the loader where pointarrays are 
created, and so it's just a case of adding lwfree(pa->points) in the 
dozen or so locations affected), but if you wish to go ahead and make 
the changes with appropriate comments then that's fine with me.

If you decide not to go ahead with it, let me know and I'll go through 
shp2pgsql and add the extra lwfree()s - I feel it's kinda my 
responsibility since it was me that recently ripped out most of the guts 
of the loader...


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063



More information about the postgis-devel mailing list