[postgis-devel] memory management questions #1
Nicklas Avén
nicklas.aven at jordogskog.no
Sun Oct 24 14:37:54 PDT 2010
Hallo
I'm trying to learn some more and are studying the distance-functions
through cunit and valgrind.
My first question is:
I think lwgeom_free and lwgeom_release seems to do much the same thing.
Why do we have both? When to use which one?
and another small question:
I found that the bbox was not released when calling lwgeom_free with
points. For other types there is a check for bbox and they are freed but
not for points in lwpoint_free.
Is that for some reason or is it a bug?
Then I have a third question that maybe wrong time to ask since Paul is
working on the parser. But I get memory leaks when using
lwgeom_from_ewkt looking like this:
==32144== 37 bytes in 1 blocks are definitely lost in loss record 2 of 3
==32144== at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==32144== by 0x42BB7F: make_serialized_lwgeom (lwgparse.c:1387)
==32144== by 0x42CA2A: parse_it (lwgparse.c:1730)
==32144== by 0x417253: serialized_lwgeom_from_ewkt (lwgeom.c:758)
==32144== by 0x417DB3: lwgeom_from_ewkt (lwgeom.c:736)
==32144== by 0x40A02F: test_mindistance2d_tolerance
(cu_measures.c:35)
==32144== by 0x50B32A9: ??? (in /usr/lib/libcunit.so.1.0.1)
==32144== by 0x50B3ACE: CU_run_test (in /usr/lib/libcunit.so.1.0.1)
==32144== by 0x411B6B: main (cu_tester.c:138)
and the test then looked like this:
static void test_mindistance2d_tolerance(void)
{
LWGEOM *lw1;
lw1 = lwgeom_from_ewkt("LINESTRING(0 0, 1 1)", PARSER_CHECK_NONE);
lwgeom_free(lw1);
}
As I understand it we never free *serialized_lwgeom in
LWGEOM_PARSER_RESULT
and I think it should be done in lwgeom_from_ewkt after the result are
deserialized
in the structure LWGEOM_PARSER_RESULT there is also room for a pointer
to the LWGEOM version of the geometry, do we use that?
I have only tested those things above on trunk r6120 so maybe the parser
rewriting is affecting.
I am glad for any hint to help me understand.
Thanks
Nicklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20101024/ace20346/attachment.html>
More information about the postgis-devel
mailing list