[GRASS-dev] v.net.visibility memory leak? - was Re: [GRASS-user] traveling salesman problem in air

Markus Neteler neteler at osgeo.org
Thu Apr 16 09:12:12 EDT 2009


On Thu, Apr 16, 2009 at 2:41 PM, Markus Metz
<markus.metz.giswork at googlemail.com> wrote:
> Markus Neteler wrote:
>> On Thu, Apr 16, 2009 at 11:02 AM, Markus Metz
>
> Vect_destroy_line_struct(sites) and Vect_destroy_cats_struct(cats) is also
> missing in main.c, load_lines().

added...

...
And again the new valgrind output:

...
==17614== Syscall param write(buf) points to uninitialised byte(s)
==17614==    at 0x7035D70: write (in /lib64/libc-2.8.so)
==17614==    by 0x6FD6EE9: _IO_file_write (in /lib64/libc-2.8.so)
==17614==    by 0x6FD7DF8: _IO_do_write (in /lib64/libc-2.8.so)
==17614==    by 0x6FD89F6: _IO_switch_to_get_mode (in /lib64/libc-2.8.so)
==17614==    by 0x6FD736F: _IO_file_seekoff (in /lib64/libc-2.8.so)
==17614==    by 0x6FCCDA9: ftell (in /lib64/libc-2.8.so)
==17614==    by 0x5D41F4D: dig_ftell (file.c:40)
==17614==    by 0x5D42963: dig__write_head (head.c:56)
==17614==    by 0x4E57FE4: V1_open_new_nat (open_nat.c:127)
==17614==    by 0x4E57434: Vect_open_new (open.c:565)
==17614==    by 0x402F6F: main (main.c:85)
==17614==  Address 0x4028009 is not stack'd, malloc'd or (recently) free'd
Building topology for vector map <graph>...
Registering primitives...
...
==17614==
==17614== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 1)
==17614== malloc/free: in use at exit: 73,862,818 bytes in 414,663 blocks.
==17614== malloc/free: 4,047,814 allocs, 3,633,151 frees,
1,604,427,109 bytes allocated.
==17614== For counts of detected errors, rerun with: -v
==17614== searching for pointers to 414,663 not-freed blocks.
==17614== checked 73,072,728 bytes.
==17614==
==17614==
==17614== 100 bytes in 1 blocks are still reachable in loss record 1 of 16
==17614==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==17614==    by 0x5D3F976: dig__alloc_space (allocation.c:81)
==17614==    by 0x5D4983D: buf_alloc (portable.c:55)
==17614==    by 0x5D49B0E: dig__fread_port_L (portable.c:150)
==17614==    by 0x5D4872D: dig_Rd_Plus_head (plus_struct.c:614)
==17614==    by 0x4E579D6: Vect_open_topo (open.c:722)
==17614==    by 0x4E5693A: Vect__open_old (open.c:229)
==17614==    by 0x4E57029: Vect_open_old (open.c:415)
==17614==    by 0x402F1F: main (main.c:81)
==17614==
==17614==
==17614== 480 bytes in 1 blocks are still reachable in loss record 2 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x5296135: G__realloc (alloc.c:109)
==17614==    by 0x4E46602: Vect_add_dblink (field.c:226)
==17614==    by 0x4E47333: Vect_read_dblinks (field.c:645)
==17614==    by 0x4E56D61: Vect__open_old (open.c:344)
==17614==    by 0x4E57029: Vect_open_old (open.c:415)
==17614==    by 0x402F1F: main (main.c:81)
==17614==
==17614==
==17614== 1,264 (64 direct, 1,200 indirect) bytes in 2 blocks are
definitely lost in loss record 3 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x4E4F2F2: Vect__new_line_struct (line.c:69)
==17614==    by 0x4E4F2A8: Vect_new_line_struct (line.c:59)
==17614==    by 0x4E3CA67: Vect_build_nat (build_nat.c:496)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 1,200 bytes in 3 blocks are indirectly lost in loss record 4 of 16
==17614==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==17614==    by 0x5D3F976: dig__alloc_space (allocation.c:81)
==17614==    by 0x5D4D415: dig_alloc_points (struct_alloc.c:248)
==17614==    by 0x4E5B200: Vect__Read_line_nat (read_nat.c:309)
==17614==    by 0x4E5AC11: V1_read_next_line_nat (read_nat.c:82)
==17614==    by 0x4E5A8EE: Vect_read_next_line (read.c:76)
==17614==    by 0x4E3CB00: Vect_build_nat (build_nat.c:522)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 3,444 bytes in 32 blocks are definitely lost in loss record 5 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x529603E: G__malloc (alloc.c:41)
==17614==    by 0x52B36F3: G__location_path (location.c:80)
==17614==    by 0x52B3644: G_location_path (location.c:41)
==17614==    by 0x52AEB0B: G__gisinit (gisinit.c:57)
==17614==    by 0x402D97: main (main.c:42)
==17614==
==17614==
==17614== 4,096 bytes in 8 blocks are definitely lost in loss record 6 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x5F545D6: RTreeNewNode (node.c:49)
==17614==    by 0x5F5364C: RTreeNewIndex (index.c:29)
==17614==    by 0x5D4B522: dig_spidx_init (spindex.c:36)
==17614==    by 0x5D43C94: dig_init_plus (plus.c:94)
==17614==    by 0x4E564B2: Vect__open_old (open.c:146)
==17614==    by 0x4E57029: Vect_open_old (open.c:415)
==17614==    by 0x402F1F: main (main.c:81)
==17614==
==17614==
==17614== 38,440 bytes in 1,356 blocks are still reachable in loss
record 7 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x4C214F7: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5D4D0A8: dig_alloc_nodes (struct_alloc.c:99)
==17614==    by 0x5D44166: dig_load_plus (plus.c:290)
==17614==    by 0x4E57AC5: Vect_open_topo (open.c:751)
==17614==    by 0x4E5693A: Vect__open_old (open.c:229)
==17614==    by 0x4E57029: Vect_open_old (open.c:415)
==17614==    by 0x402F1F: main (main.c:81)
==17614==
==17614==
==17614== 40,008 bytes in 1 blocks are still reachable in loss record 8 of 16
==17614==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5D4D0A8: dig_alloc_nodes (struct_alloc.c:99)
==17614==    by 0x5D46D50: dig_add_node (plus_node.c:116)
==17614==    by 0x5D461D1: add_line (plus_line.c:55)
==17614==    by 0x5D46379: dig_add_line (plus_line.c:114)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 248,016 bytes in 5,167 blocks are still reachable in loss
record 9 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x5D4CF59: dig_alloc_node (struct_alloc.c:44)
==17614==    by 0x5D46D93: dig_add_node (plus_node.c:123)
==17614==    by 0x5D461D1: add_line (plus_line.c:55)
==17614==    by 0x5D46379: dig_add_line (plus_line.c:114)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 449,106 bytes in 56 blocks are still reachable in loss record 10 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x529603E: G__malloc (alloc.c:41)
==17614==    by 0x52CE929: G_store (store.c:36)
==17614==    by 0x52C29D9: G_set_program_name (progrm_nme.c:52)
==17614==    by 0x52AEAD2: G__gisinit (gisinit.c:51)
==17614==    by 0x402D97: main (main.c:42)
==17614==
==17614==
==17614== 2,645,144 bytes in 4,491 blocks are still reachable in loss
record 11 of 16
==17614==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5D4CFF9: dig_node_alloc_line (struct_alloc.c:72)
==17614==    by 0x5D46B28: dig_node_add_line (plus_node.c:56)
==17614==    by 0x5D4622F: add_line (plus_line.c:64)
==17614==    by 0x5D46379: dig_add_line (plus_line.c:114)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 2,645,144 bytes in 4,491 blocks are still reachable in loss
record 12 of 16
==17614==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5D4D033: dig_node_alloc_line (struct_alloc.c:77)
==17614==    by 0x5D46B28: dig_node_add_line (plus_node.c:56)
==17614==    by 0x5D4622F: add_line (plus_line.c:64)
==17614==    by 0x5D46379: dig_add_line (plus_line.c:114)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 2,648,008 bytes in 1 blocks are still reachable in loss
record 13 of 16
==17614==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5D4D15B: dig_alloc_lines (struct_alloc.c:133)
==17614==    by 0x5D46344: dig_add_line (plus_line.c:110)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 4,020,144 bytes in 3 blocks are still reachable in loss
record 14 of 16
==17614==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==17614==    by 0x5296148: G__realloc (alloc.c:111)
==17614==    by 0x52A4EB2: set_env (env.c:156)
==17614==    by 0x52A4C44: read_env (env.c:104)
==17614==    by 0x52A54CE: G__getenv (env.c:317)
==17614==    by 0x52A5410: G_getenv (env.c:271)
==17614==    by 0x52B36A0: G_location (location.c:63)
==17614==    by 0x52B36B8: G__location_path (location.c:78)
==17614==    by 0x52B3644: G_location_path (location.c:41)
==17614==    by 0x52AEB0B: G__gisinit (gisinit.c:57)
==17614==    by 0x402D97: main (main.c:42)


comment:
http://trac.osgeo.org/grass/ticket/14


==17614==
==17614==
==17614== 26,517,440 bytes in 331,468 blocks are still reachable in
loss record 15 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x5D4D0F9: dig_alloc_line (struct_alloc.c:114)
==17614==    by 0x5D45F40: add_line (plus_line.c:27)
==17614==    by 0x5D46379: dig_add_line (plus_line.c:114)
==17614==    by 0x4E3CB9B: Vect_build_nat (build_nat.c:538)
==17614==    by 0x4E3AD22: Vect_build_partial (build.c:134)
==17614==    by 0x4E3AC15: Vect_build (build.c:55)
==17614==    by 0x40320C: main (main.c:132)
==17614==
==17614==
==17614== 34,601,984 bytes in 67,582 blocks are still reachable in
loss record 16 of 16
==17614==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==17614==    by 0x5F545D6: RTreeNewNode (node.c:49)
==17614==    by 0x5F56AF6: RTreeSplitNode (split_q.c:313)
==17614==    by 0x5F54E52: RTreeAddBranch (node.c:201)
==17614==    by 0x5F53BA3: RTreeInsertRect2 (index.c:121)
==17614==    by 0x5F5398A: RTreeInsertRect2 (index.c:102)
==17614==    by 0x5F5398A: RTreeInsertRect2 (index.c:102)
==17614==    by 0x5F5398A: RTreeInsertRect2 (index.c:102)
==17614==    by 0x5F5398A: RTreeInsertRect2 (index.c:102)
==17614==    by 0x5F5398A: RTreeInsertRect2 (index.c:102)
==17614==    by 0x5F53D81: RTreeInsertRect1 (index.c:162)
==17614==    by 0x5F53C2F: RTreeInsertRect (index.c:141)
==17614==
==17614== LEAK SUMMARY:
==17614==    definitely lost: 7,604 bytes in 42 blocks.
==17614==    indirectly lost: 1,200 bytes in 3 blocks.
==17614==      possibly lost: 0 bytes in 0 blocks.
==17614==    still reachable: 73,854,014 bytes in 414,618 blocks.
==17614==         suppressed: 0 bytes in 0 blocks.


not much changed...

>> I assume that the Vect_set_release_support() was suggested only for
>> debugging.
>>
>
> Not really, it is cleaning up memory. No idea why this is not done by
> default in the vector libs every time a vector is closed. Somewhere there is
> a comment in the Programmer's manual that it can take a lot of time, maybe
> that's the reason why it is not done by default.
>
> Markus M
>


More information about the grass-dev mailing list