On Thu, Apr 16, 2009 at 11:02 AM, Markus Metz <[email protected]> wrote: > Markus Neteler wrote: >> On Thu, Apr 16, 2009 at 8:28 AM, Markus Metz >>> 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(). >> > > I'm missing Vect_destroy_line_struct(sites) and > Vect_destroy_cats_struct(cats) in visibility.c, report() and main.c, > count(). Maybe that helps.
added... > Further on, it seems that... > - Something's wrong with the RTree, I guess with re-inserting nodes. > Debugging the RTree is a major nightmare... I can imagine :( > - Memory allocated by buf_alloc() in diglib is never free-d, must be fixed > in diglib, in theory easy. ok... [btw: Attaching centroids... 100% centroids: 1.000000 areas to cidx: 0.000000 <<--- should this be G_debug()? Number of nodes: 4491 Number of primitives: 330643 ] That's in lib/vector/Vlib/build_nat.c # ------------------------------ Here the new valgrind output: ==16713== WARNING: Vector map <graph> already exists and will be overwritten ==16713== Syscall param write(buf) points to uninitialised byte(s) ==16713== at 0x7035D70: write (in /lib64/libc-2.8.so) ==16713== by 0x6FD6EE9: _IO_file_write (in /lib64/libc-2.8.so) ==16713== by 0x6FD7DF8: _IO_do_write (in /lib64/libc-2.8.so) ==16713== by 0x6FD89F6: _IO_switch_to_get_mode (in /lib64/libc-2.8.so) ==16713== by 0x6FD736F: _IO_file_seekoff (in /lib64/libc-2.8.so) ==16713== by 0x6FCCDA9: ftell (in /lib64/libc-2.8.so) ==16713== by 0x5D41F4D: dig_ftell (file.c:40) ==16713== by 0x5D42963: dig__write_head (head.c:56) ==16713== by 0x4E57FE4: V1_open_new_nat (open_nat.c:127) ==16713== by 0x4E57434: Vect_open_new (open.c:565) ==16713== by 0x402FCF: main (main.c:85) ==16713== 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: 422.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 ==16713== ==16713== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 1) ==16713== malloc/free: in use at exit: 455,310 bytes in 119 blocks. ==16713== malloc/free: 4,047,822 allocs, 4,047,703 frees, 1,604,431,177 bytes allocated. ==16713== For counts of detected errors, rerun with: -v ==16713== searching for pointers to 119 not-freed blocks. ==16713== checked 2,415,312 bytes. ==16713== ==16713== ==16713== 100 bytes in 1 blocks are still reachable in loss record 1 of 10 ==16713== at 0x4C1F144: calloc (vg_replace_malloc.c:397) ==16713== by 0x5D3F976: dig__alloc_space (allocation.c:81) ==16713== by 0x5D4983D: buf_alloc (portable.c:55) ==16713== by 0x5D49B0E: dig__fread_port_L (portable.c:150) ==16713== by 0x5D4872D: dig_Rd_Plus_head (plus_struct.c:614) ==16713== by 0x4E579D6: Vect_open_topo (open.c:722) ==16713== by 0x4E5693A: Vect__open_old (open.c:229) ==16713== by 0x4E57029: Vect_open_old (open.c:415) ==16713== by 0x402F7F: main (main.c:81) ==16713== ==16713== ==16713== 144 bytes in 2 blocks are still reachable in loss record 2 of 10 ==16713== at 0x4C214A1: realloc (vg_replace_malloc.c:429) ==16713== by 0x5296148: G__realloc (alloc.c:111) ==16713== by 0x52A4EB2: set_env (env.c:156) ==16713== by 0x52A4C44: read_env (env.c:104) ==16713== by 0x52A54CE: G__getenv (env.c:317) ==16713== by 0x52A5410: G_getenv (env.c:271) ==16713== by 0x52B36A0: G_location (location.c:63) ==16713== by 0x52B36B8: G__location_path (location.c:78) ==16713== by 0x52B3644: G_location_path (location.c:41) ==16713== by 0x52AEB0B: G__gisinit (gisinit.c:57) ==16713== by 0x402DF7: main (main.c:42) ==16713== ==16713== ==16713== 480 bytes in 1 blocks are still reachable in loss record 3 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x5296135: G__realloc (alloc.c:109) ==16713== by 0x4E46602: Vect_add_dblink (field.c:226) ==16713== by 0x4E47333: Vect_read_dblinks (field.c:645) ==16713== by 0x4E56D61: Vect__open_old (open.c:344) ==16713== by 0x4E57029: Vect_open_old (open.c:415) ==16713== by 0x402F7F: main (main.c:81) ==16713== ==16713== ==16713== 3,492 (3,468 direct, 24 indirect) bytes in 33 blocks are definitely lost in loss record 4 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x529603E: G__malloc (alloc.c:41) ==16713== by 0x52B36F3: G__location_path (location.c:80) ==16713== by 0x52B3644: G_location_path (location.c:41) ==16713== by 0x52AEB0B: G__gisinit (gisinit.c:57) ==16713== by 0x402DF7: main (main.c:42) ==16713== ==16713== ==16713== 3,696 (96 direct, 3,600 indirect) bytes in 3 blocks are definitely lost in loss record 5 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x4E4F2F2: Vect__new_line_struct (line.c:69) ==16713== by 0x4E4F2A8: Vect_new_line_struct (line.c:59) ==16713== by 0x40360E: load_lines (main.c:242) ==16713== by 0x4031B1: main (main.c:119) ==16713== ==16713== ==16713== 1,224 bytes in 5 blocks are indirectly lost in loss record 6 of 10 ==16713== at 0x4C1F144: calloc (vg_replace_malloc.c:397) ==16713== by 0x5D3F976: dig__alloc_space (allocation.c:81) ==16713== by 0x5D4D4CD: dig_alloc_cats (struct_alloc.c:279) ==16713== by 0x4E5B07E: Vect__Read_line_nat (read_nat.c:266) ==16713== by 0x4E5AD24: V2_read_line_nat (read_nat.c:138) ==16713== by 0x4E5AE99: V2_read_next_line_nat (read_nat.c:192) ==16713== by 0x4E5A8EE: Vect_read_next_line (read.c:76) ==16713== by 0x4036C0: load_lines (main.c:245) ==16713== by 0x4031B1: main (main.c:119) ==16713== ==16713== ==16713== 2,400 bytes in 3 blocks are indirectly lost in loss record 7 of 10 ==16713== at 0x4C1F144: calloc (vg_replace_malloc.c:397) ==16713== by 0x5D3FAF5: dig__frealloc (allocation.c:144) ==16713== by 0x5D3F991: dig__alloc_space (allocation.c:83) ==16713== by 0x5D4D3C9: dig_alloc_points (struct_alloc.c:239) ==16713== by 0x4E5B200: Vect__Read_line_nat (read_nat.c:309) ==16713== by 0x4E5AD24: V2_read_line_nat (read_nat.c:138) ==16713== by 0x4E5AE99: V2_read_next_line_nat (read_nat.c:192) ==16713== by 0x4E5A8EE: Vect_read_next_line (read.c:76) ==16713== by 0x4036C0: load_lines (main.c:245) ==16713== by 0x4031B1: main (main.c:119) ==16713== ==16713== ==16713== 4,096 bytes in 8 blocks are still reachable in loss record 8 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x5F545D6: RTreeNewNode (node.c:49) ==16713== by 0x5F5364C: RTreeNewIndex (index.c:29) ==16713== by 0x5D4B68D: dig_spidx_free_isles (spindex.c:93) ==16713== by 0x5D4B6CD: dig_spidx_free (spindex.c:106) ==16713== by 0x4E40BA8: Vect_close (close.c:117) ==16713== by 0x403290: main (main.c:135) ==16713== ==16713== ==16713== 4,096 bytes in 8 blocks are definitely lost in loss record 9 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x5F545D6: RTreeNewNode (node.c:49) ==16713== by 0x5F5364C: RTreeNewIndex (index.c:29) ==16713== by 0x5D4B522: dig_spidx_init (spindex.c:36) ==16713== by 0x5D43C94: dig_init_plus (plus.c:94) ==16713== by 0x4E564B2: Vect__open_old (open.c:146) ==16713== by 0x4E57029: Vect_open_old (open.c:415) ==16713== by 0x402F7F: main (main.c:81) ==16713== ==16713== ==16713== 439,206 bytes in 55 blocks are still reachable in loss record 10 of 10 ==16713== at 0x4C2136E: malloc (vg_replace_malloc.c:207) ==16713== by 0x529603E: G__malloc (alloc.c:41) ==16713== by 0x52CE929: G_store (store.c:36) ==16713== by 0x52C29D9: G_set_program_name (progrm_nme.c:52) ==16713== by 0x52AEAD2: G__gisinit (gisinit.c:51) ==16713== by 0x402DF7: main (main.c:42) ==16713== ==16713== LEAK SUMMARY: ==16713== definitely lost: 7,660 bytes in 44 blocks. ==16713== indirectly lost: 3,624 bytes in 8 blocks. ==16713== possibly lost: 0 bytes in 0 blocks. ==16713== still reachable: 444,026 bytes in 67 blocks. ==16713== suppressed: 0 bytes in 0 blocks. This looks definitely better! I assume that the Vect_set_release_support() was suggested only for debugging. Fixed in 6.4.0svn, 6.5.svn and 7 as r36752, r36753, r36754. Thanks, MarkusM for spotting the problem. Markus _______________________________________________ grass-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-dev
