[GRASS5] Re: Vector points and topology

Markus Neteler neteler at itc.it
Fri Jul 29 12:34:10 EDT 2005


Hi,

I was looking again (a bit) at the potential memory leak
of the vector library.

Hamish's analysis
 http://bambi.otago.ac.nz/hamish/grass/memleak/v.in.ascii/
indicates
  The main offenders are:
    RTreeNewNode (node.c:47)
    dig_alloc_node (struct_alloc.c:46)
    dig_alloc_lines (struct_alloc.c:130)

Looking at the code:

lib/vector/rtree > grep RTreeNewNode *.c
index.c:        x = RTreeNewNode();
index.c:                newroot = RTreeNewNode();  /* grow a new root, & tree taller */
node.c:struct Node * RTreeNewNode(void)
split_l.c:      *nn = RTreeNewNode();
split_q.c:      *nn = RTreeNewNode();

I see that RTreeNewNode() - which uses malloc() is used a couple of times
but probably free() isn't used where needed:

lib/vector/rtree > grep free *.c | grep -iv 'free software'
index.c:        free(p);
node.c: free(p);
node.c:/* Destroy (free) node recursively. */

Maybe someone knowing more that me could inspect if a free() is
missing here? RTreeNewNode(), according to valgrind, seems to
cause some troubles.

Markus




More information about the grass-dev mailing list