[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 04:32:11 EDT 2009


On Thu, Apr 16, 2009 at 8:28 AM, Markus Metz
<markus.metz.giswork at googlemail.com> wrote:
> Markus Neteler wrote:
...
>> I have run valgrind to check for a memory leak (Linux 64 bit box):
>> Some funky "uninitialised byte(s)" problem appears... (inline also a
>> debug msg?):
>>
>
> Some leaks in the vector libs could disappear if Vect_set_release_support()
> is called just before closing vectors in v.net.visibility. Maybe the output
> of valgrind becomes a bit shorter and more readable.

I have added for input and output  Vect_set_release_support().
Now it looks like this:

GRASS 6.5.svn (spearfish60):~ > CMD="v.net.visibility input=roads
output=graph --o"
GRASS 6.5.svn (spearfish60):~ > valgrind --tool=memcheck
--leak-check=yes --show-reachable=yes  $CMD --o
==3746== Memcheck, a memory error detector.
==3746== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et
al.
==3746== Using LibVEX rev 1854, a library for dynamic binary
translation.
==3746== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==3746== Using valgrind-3.3.1, a dynamic binary instrumentation
framework.
==3746== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et
al.
==3746== For more details, rerun with: -v
==3746==
WARNING: Vector map <graph> already exists and will be overwritten
==3746== Syscall param write(buf) points to uninitialised byte(s)
==3746==    at 0x7035D70: write (in /lib64/libc-2.8.so)
==3746==    by 0x6FD6EE9: _IO_file_write (in /lib64/libc-2.8.so)
==3746==    by 0x6FD7DF8: _IO_do_write (in /lib64/libc-2.8.so)
==3746==    by 0x6FD89F6: _IO_switch_to_get_mode (in
/lib64/libc-2.8.so)
==3746==    by 0x6FD736F: _IO_file_seekoff (in /lib64/libc-2.8.so)
==3746==    by 0x6FCCDA9: ftell (in /lib64/libc-2.8.so)
==3746==    by 0x5D41F4D: dig_ftell (file.c:40)
==3746==    by 0x5D42963: dig__write_head (head.c:56)
==3746==    by 0x4E57FE4: V1_open_new_nat (open_nat.c:127)
==3746==    by 0x4E57434: Vect_open_new (open.c:565)
==3746==    by 0x402F0F: main (main.c:85)
==3746==  Address 0x4028009 is not stack'd, malloc'd or (recently)
free'd
Building topology for vector map <graph>...
Registering primitives...
330643 primitives registered
661286 vertices registered
primitives: 428.000000
Building areas...
 100%
0 areas built
0 isles built
areas: 1.000000
Attaching islands...
isles: 0.000000
Attaching centroids...
 100%
centroids: 1.000000
areas to cidx: 0.000000
Number of nodes: 4491
Number of primitives: 330643
Number of points: 0
Number of lines: 330643
Number of boundaries: 0
Number of centroids: 0
Number of areas: 0
Number of isles: 0
==3746==
==3746== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from
1)
==3746== malloc/free: in use at exit: 415,745,397 bytes in 1,653,341
blocks.
==3746== malloc/free: 4,047,822 allocs, 2,394,481 frees, 1,604,431,184
bytes allocated.
==3746== For counts of detected errors, rerun with: -v
==3746== searching for pointers to 1,653,341 not-freed blocks.
==3746== checked 2,661,584 bytes.
==3746==
==3746==
==3746== 96 bytes in 3 blocks are still reachable in loss record 1 of
14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x4E4F2F2: Vect__new_line_struct (line.c:69)
==3746==    by 0x4E4F2A8: Vect_new_line_struct (line.c:59)
==3746==    by 0x404F23: report (visibility.c:211)
==3746==    by 0x404BD9: handle (visibility.c:164)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 144 bytes in 2 blocks are still reachable in loss record 2 of
14
==3746==    at 0x4C214A1: realloc (vg_replace_malloc.c:429)
==3746==    by 0x5296148: G__realloc (alloc.c:111)
==3746==    by 0x52A4EB2: set_env (env.c:156)
==3746==    by 0x52A4C44: read_env (env.c:104)
==3746==    by 0x52A54CE: G__getenv (env.c:317)
==3746==    by 0x52A5410: G_getenv (env.c:271)
==3746==    by 0x52B36A0: G_location (location.c:63)
==3746==    by 0x52B36B8: G__location_path (location.c:78)
==3746==    by 0x52B3644: G_location_path (location.c:41)
==3746==    by 0x52AEB0B: G__gisinit (gisinit.c:57)
==3746==    by 0x402D37: main (main.c:42)
==3746==
==3746==
==3746== 360 bytes in 15 blocks are possibly lost in loss record 3 of
14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x529603E: G__malloc (alloc.c:41)
==3746==    by 0x4E3E213: Vect__new_cats_struct (cats.c:62)
==3746==    by 0x4E3E1C4: Vect_new_cats_struct (cats.c:44)
==3746==    by 0x404F2C: report (visibility.c:212)
==3746==    by 0x404CE8: handle (visibility.c:176)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 384 bytes in 12 blocks are possibly lost in loss record 4 of
14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x4E4F2F2: Vect__new_line_struct (line.c:69)
==3746==    by 0x4E4F2A8: Vect_new_line_struct (line.c:59)
==3746==    by 0x404F23: report (visibility.c:211)
==3746==    by 0x404CE8: handle (visibility.c:176)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 480 bytes in 1 blocks are still reachable in loss record 5 of
14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x5296135: G__realloc (alloc.c:109)
==3746==    by 0x4E46602: Vect_add_dblink (field.c:226)
==3746==    by 0x4E47333: Vect_read_dblinks (field.c:645)
==3746==    by 0x4E56D61: Vect__open_old (open.c:344)
==3746==    by 0x4E57029: Vect_open_old (open.c:415)
==3746==    by 0x402EBF: main (main.c:81)
==3746==
==3746==
==3746== 4,096 bytes in 8 blocks are still reachable in loss record 6
of 14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x5F545D6: RTreeNewNode (node.c:49)
==3746==    by 0x5F5364C: RTreeNewIndex (index.c:29)
==3746==    by 0x5D4B65C: dig_spidx_free_areas (spindex.c:82)
==3746==    by 0x5D4B6C4: dig_spidx_free (spindex.c:105)
==3746==    by 0x4E40BA8: Vect_close (close.c:117)
==3746==    by 0x4031DC: main (main.c:136)
==3746==
==3746==
==3746== 4,096 bytes in 8 blocks are definitely lost in loss record 7
of 14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x5F545D6: RTreeNewNode (node.c:49)
==3746==    by 0x5F5364C: RTreeNewIndex (index.c:29)
==3746==    by 0x5D4B522: dig_spidx_init (spindex.c:36)
==3746==    by 0x5D43C94: dig_init_plus (plus.c:94)
==3746==    by 0x4E564B2: Vect__open_old (open.c:146)
==3746==    by 0x4E57029: Vect_open_old (open.c:415)
==3746==    by 0x402EBF: main (main.c:81)
==3746==
==3746==
==3746== 4,800 bytes in 6 blocks are indirectly lost in loss record 8
of 14
==3746==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==3746==    by 0x5D3FAF5: dig__frealloc (allocation.c:144)
==3746==    by 0x5D3F991: dig__alloc_space (allocation.c:83)
==3746==    by 0x5D4D3C9: dig_alloc_points (struct_alloc.c:239)
==3746==    by 0x4E5B200: Vect__Read_line_nat (read_nat.c:309)
==3746==    by 0x4E5AD24: V2_read_line_nat (read_nat.c:138)
==3746==    by 0x4E5A9E3: Vect_read_line (read.c:106)
==3746==    by 0x40347B: count (main.c:202)
==3746==    by 0x403046: main (main.c:108)
==3746==
==3746==
==3746== 21,300 bytes in 54 blocks are still reachable in loss record
9 of 14
==3746==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==3746==    by 0x5D3F976: dig__alloc_space (allocation.c:81)
==3746==    by 0x5D4983D: buf_alloc (portable.c:55)
==3746==    by 0x5D49B0E: dig__fread_port_L (portable.c:150)
==3746==    by 0x5D4872D: dig_Rd_Plus_head (plus_struct.c:614)
==3746==    by 0x4E579D6: Vect_open_topo (open.c:722)
==3746==    by 0x4E5693A: Vect__open_old (open.c:229)
==3746==    by 0x4E57029: Vect_open_old (open.c:415)
==3746==    by 0x402EBF: main (main.c:81)
==3746==
==3746==
==3746== 224,400 bytes in 561 blocks are possibly lost in loss record
10 of 14
==3746==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==3746==    by 0x5D3F976: dig__alloc_space (allocation.c:81)
==3746==    by 0x5D4D3C9: dig_alloc_points (struct_alloc.c:239)
==3746==    by 0x4E4F3CA: Vect_copy_xyz_to_pnts (line.c:118)
==3746==    by 0x404F8E: report (visibility.c:219)
==3746==    by 0x404ED3: handle (visibility.c:198)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 439,326 bytes in 60 blocks are still reachable in loss record
11 of 14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x529603E: G__malloc (alloc.c:41)
==3746==    by 0x52CE929: G_store (store.c:36)
==3746==    by 0x52C29D9: G_set_program_name (progrm_nme.c:52)
==3746==    by 0x52AEAD2: G__gisinit (gisinit.c:51)
==3746==    by 0x402D37: main (main.c:42)
==3746==
==3746==
==3746== 7,938,491 (7,938,443 direct, 48 indirect) bytes in 330,657
blocks are definitely lost in loss record 12 of 14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x529603E: G__malloc (alloc.c:41)
==3746==    by 0x4E3E213: Vect__new_cats_struct (cats.c:62)
==3746==    by 0x4E3E1C4: Vect_new_cats_struct (cats.c:44)
==3746==    by 0x404F2C: report (visibility.c:212)
==3746==    by 0x404ED3: handle (visibility.c:198)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 407,112,224 (10,580,224 direct, 396,532,000 indirect) bytes
in 330,632 blocks are definitely lost in loss record 13 of14
==3746==    at 0x4C2136E: malloc (vg_replace_malloc.c:207)
==3746==    by 0x4E4F2F2: Vect__new_line_struct (line.c:69)
==3746==    by 0x4E4F2A8: Vect_new_line_struct (line.c:59)
==3746==    by 0x404F23: report (visibility.c:211)
==3746==    by 0x404ED3: handle (visibility.c:198)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746==
==3746== 396,527,248 bytes in 991,322 blocks are indirectly lost in
loss record 14 of 14
==3746==    at 0x4C1F144: calloc (vg_replace_malloc.c:397)
==3746==    by 0x5D3F976: dig__alloc_space (allocation.c:81)
==3746==    by 0x5D4D3C9: dig_alloc_points (struct_alloc.c:239)
==3746==    by 0x4E4F3CA: Vect_copy_xyz_to_pnts (line.c:118)
==3746==    by 0x404F8E: report (visibility.c:219)
==3746==    by 0x404BD9: handle (visibility.c:164)
==3746==    by 0x40515F: construct_visibility (visibility.c:278)
==3746==    by 0x40314F: main (main.c:125)
==3746==
==3746== LEAK SUMMARY:
==3746==    definitely lost: 18,522,763 bytes in 661,297 blocks.
==3746==    indirectly lost: 396,532,048 bytes in 991,328 blocks.
==3746==      possibly lost: 225,144 bytes in 588 blocks.
==3746==    still reachable: 465,442 bytes in 128 blocks.
==3746==         suppressed: 0 bytes in 0 blocks.

Markus


More information about the grass-dev mailing list