[postgis-devel] memory management questions #1

Nicklas Avén nicklas.aven at jordogskog.no
Mon Oct 25 13:26:19 PDT 2010



> Right. I discovered this leak when I was testing the new pgsql2shp code 
> in trunk, and the short version is that there is an incredibly naive 
> piece of coding in the existing parser alloc_tuple() that throws away 
> malloc() linked lists in certain circumstances.
> 
> I did try and come up with a workaround by tracking lists of lists, but 
> that then caused other errors to appear all through the parser. Since it 
> was something that could not be fixed without substantial work, I came 
> to the conclusion that we're much better off going with Paul's new 
> version and investing the time/effort there instead. So I can't see this 
> ever getting fixed in the current parser I'm afraid :(
> 
> 
> ATB,
> 
> Mark.
> 



I realize that this was more scary than imagined. 

BTW, when I chased away the serialized form from measures.c I did :
geom1 = lwgeom_deserialize(SERIALIZED_FORM((PG_LWGEOM
*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0))));

I saw now that most other functions do:

PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
PG_FREE_IF_COPY(geom, 0);


When are they copied and should get freed. Is that the same thing but on
the serialized form that Paul discussed that it depends if the geoemtry
comes from the database or from text represention?

When I don't use :
PG_FREE_IF_COPY(geom, 0);

will that give a more severe leak since it is postgres stuff?

/Nicklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20101025/a28cd458/attachment.html>


More information about the postgis-devel mailing list