[GRASS-dev] Re: [GRASS GIS] #14: libgis and libvect memory leaks

GRASS GIS trac at osgeo.org
Mon Oct 3 16:54:31 EDT 2011


#14: libgis and libvect memory leaks
---------------------+------------------------------------------------------
 Reporter:  neteler  |       Owner:  grass-dev@…              
     Type:  defect   |      Status:  new                      
 Priority:  major    |   Milestone:  6.4.2                    
Component:  Default  |     Version:  svn-trunk                
 Keywords:  library  |    Platform:  Linux                    
      Cpu:  x86-64   |  
---------------------+------------------------------------------------------
Changes (by neteler):

  * platform:  => Linux
  * cpu:  => x86-64
  * milestone:  6.4.0 => 6.4.2


Comment:

 I have tried again in 6.4.svn and latlong location:
 {{{
 GRASS 6.4.2svn (latlong): > v.random -z random n=50 zmin=0 zmax=1000  --o
 ...
 GRASS 6.4.2svn (latlong): > CMD="v.distance -p -a random to=random
 upload=dist col=distance"
 GRASS 6.4.2svn (latlong): > valgrind --tool=memcheck --leak-check=yes
 --show-reachable=yes  $CMD --o
 ==29334== Memcheck, a memory error detector
 ==29334== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
 ==29334== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright
 info
 ==29334== Command: v.distance -p -a random to=random upload=dist
 col=distance --o
 ==29334==
  100%
  100%
  100%
 from_cat|distance
 |1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50
 1|0.000000|...|32734.380864|23046.856804
 ==29334== Conditional jump or move depends on uninitialised value(s)
 ==29334==    at 0x405233: main (main.c:880)
 ==29334==
 ==29334== Conditional jump or move depends on uninitialised value(s)
 ==29334==    at 0x40525B: main (main.c:882)
 ==29334==
 ==29334== Conditional jump or move depends on uninitialised value(s)
 ==29334==    at 0x406444: print_upload (main.c:1209)
 ==29334==    by 0x405444: main (main.c:908)
 ==29334==
 3|12556.339237|25370.513554|0.000000|26554.768615|20852.698295|25627.160524|31327.845332|44054.011005|12806.274846|31899.906958|45010.468266|33262.426524|37211.815414|24066.675903|26842.672920|2...
 |17314.385880|39790.227209|0.000000
 414 categories with more than 1 feature in vector map <random>
 v.distance complete.
 ==29334==
 ==29334== HEAP SUMMARY:
 ==29334==     in use at exit: 300,551 bytes in 714 blocks
 ==29334==   total heap usage: 96,312 allocs, 95,598 frees, 24,523,587
 bytes allocated
 ==29334==
 ==29334== 1 bytes in 1 blocks are still reachable in loss record 1 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52D6DB7: G_store (store.c:36)
 ==29334==    by 0x4E4EEA3: Vect_set_organization (header.c:258)
 ==29334==    by 0x4E4EAAC: Vect__read_head (header.c:160)
 ==29334==    by 0x4E5CB8D: Vect__open_old (open.c:209)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 1 bytes in 1 blocks are still reachable in loss record 2 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52D6DB7: G_store (store.c:36)
 ==29334==    by 0x4E4EEF9: Vect_set_date (header.c:289)
 ==29334==    by 0x4E4EAE6: Vect__read_head (header.c:162)
 ==29334==    by 0x4E5CB8D: Vect__open_old (open.c:209)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 1 bytes in 1 blocks are still reachable in loss record 3 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52D6DB7: G_store (store.c:36)
 ==29334==    by 0x4E4EFA5: Vect_set_map_name (header.c:346)
 ==29334==    by 0x4E4EB5A: Vect__read_head (header.c:166)
 ==29334==    by 0x4E5CB8D: Vect__open_old (open.c:209)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 1 bytes in 1 blocks are still reachable in loss record 4 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52D6DB7: G_store (store.c:36)
 ==29334==    by 0x4E4F089: Vect_set_comment (header.c:426)
 ==29334==    by 0x4E4EC11: Vect__read_head (header.c:172)
 ==29334==    by 0x4E5CB8D: Vect__open_old (open.c:209)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ... [tons of tiny things omitted]

 ==29334==
 ==29334== 136 bytes in 3 blocks are still reachable in loss record 73 of
 150
 ==29334==    at 0x4C235C7: calloc (vg_replace_malloc.c:418)
 ==29334==    by 0x529D1EF: G__calloc (alloc.c:74)
 ==29334==    by 0x52C1BEF: G_parser (parser.c:784)
 ==29334==    by 0x402957: main (main.c:227)
 ==29334==

 ...

 ==29334== 568 bytes in 1 blocks are still reachable in loss record 136 of
 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x6FE1544: fdopen@@GLIBC_2.2.5 (in /lib64/libc-2.11.1.so)
 ==29334==    by 0x52BE0EA: G_fopen_old (open.c:234)
 ==29334==    by 0x4E5D20B: Vect__open_old (open.c:366)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403065: main (main.c:311)
 ==29334==
 ==29334== 600 bytes in 1 blocks are still reachable in loss record 137 of
 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D45DFF: dig_read_cidx (cindex_rw.c:281)
 ==29334==    by 0x4E4567D: Vect_cidx_open (cindex.c:518)
 ==29334==    by 0x4E5CCD7: Vect__open_old (open.c:252)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 600 bytes in 1 blocks are still reachable in loss record 138 of
 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D45DFF: dig_read_cidx (cindex_rw.c:281)
 ==29334==    by 0x4E4567D: Vect_cidx_open (cindex.c:518)
 ==29334==    by 0x4E5CCD7: Vect__open_old (open.c:252)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403065: main (main.c:311)
 ==29334==
 ==29334== 800 bytes in 10 blocks are still reachable in loss record 139 of
 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52C6E4C: split_opts (parser.c:2472)
 ==29334==    by 0x52C246B: G_parser (parser.c:978)
 ==29334==    by 0x402957: main (main.c:227)
 ==29334==
 ==29334== 952 bytes in 54 blocks are still reachable in loss record 140 of
 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x52D6DB7: G_store (store.c:36)
 ==29334==    by 0x52B2412: read_ellipsoid_table (get_ellipse.c:309)
 ==29334==    by 0x52B1C43: G_get_ellipsoid_by_name (get_ellipse.c:114)
 ==29334==    by 0x52B27B4: get_ellipsoid_parameters (get_ellipse.c:370)
 ==29334==    by 0x52B1C09: G_get_ellipsoid_parameters (get_ellipse.c:89)
 ==29334==    by 0x52AB985: G_begin_distance_calculations (distance.c:51)
 ==29334==    by 0x4E56048: Vect_line_geodesic_length (line.c:585)
 ==29334==    by 0x403DBF: main (main.c:562)
 ==29334==
 ==29334== 2,160 bytes in 1 blocks are still reachable in loss record 141
 of 150
 ==29334==    at 0x4C2439D: realloc (vg_replace_malloc.c:476)
 ==29334==    by 0x529D28D: G__realloc (alloc.c:111)
 ==29334==    by 0x52B23A6: read_ellipsoid_table (get_ellipse.c:306)
 ==29334==    by 0x52B1C43: G_get_ellipsoid_by_name (get_ellipse.c:114)
 ==29334==    by 0x52B27B4: get_ellipsoid_parameters (get_ellipse.c:370)
 ==29334==    by 0x52B1C09: G_get_ellipsoid_parameters (get_ellipse.c:89)
 ==29334==    by 0x52AB985: G_begin_distance_calculations (distance.c:51)
 ==29334==    by 0x4E56048: Vect_line_geodesic_length (line.c:585)
 ==29334==    by 0x403DBF: main (main.c:562)
 ==29334==
 ==29334== 2,400 bytes in 50 blocks are still reachable in loss record 142
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D512F1: dig_alloc_node (struct_alloc.c:44)
 ==29334==    by 0x5D4B183: dig_Rd_P_node (plus_struct.c:66)
 ==29334==    by 0x5D4821B: dig_load_plus (plus.c:292)
 ==29334==    by 0x4E5DF39: Vect_open_topo (open.c:751)
 ==29334==    by 0x4E5CC41: Vect__open_old (open.c:229)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 2,400 bytes in 50 blocks are still reachable in loss record 143
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D512F1: dig_alloc_node (struct_alloc.c:44)
 ==29334==    by 0x5D4B183: dig_Rd_P_node (plus_struct.c:66)
 ==29334==    by 0x5D4821B: dig_load_plus (plus.c:292)
 ==29334==    by 0x4E5DF39: Vect_open_topo (open.c:751)
 ==29334==    by 0x4E5CC41: Vect__open_old (open.c:229)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403065: main (main.c:311)
 ==29334==
 ==29334== 3,584 bytes in 7 blocks are still reachable in loss record 144
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x5F59525: RTreeNewNode (node.c:49)
 ==29334==    by 0x5F5B921: RTreeSplitNode (split_q.c:313)
 ==29334==    by 0x5F59D07: RTreeAddBranch (node.c:201)
 ==29334==    by 0x5F58B9E: RTreeInsertRect2 (index.c:121)
 ==29334==    by 0x5F58982: RTreeInsertRect2 (index.c:102)
 ==29334==    by 0x5F58D3F: RTreeInsertRect1 (index.c:162)
 ==29334==    by 0x5F58C25: RTreeInsertRect (index.c:141)
 ==29334==    by 0x5D4F929: dig_spidx_add_node (spindex.c:134)
 ==29334==    by 0x4E64160: Vect_build_sidx_from_topo (sindex.c:170)
 ==29334==    by 0x4E634C7: Vect_select_lines_by_box (select.c:53)
 ==29334==    by 0x403B95: main (main.c:534)
 ==29334==
 ==29334== 3,584 bytes in 7 blocks are still reachable in loss record 145
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x5F59525: RTreeNewNode (node.c:49)
 ==29334==    by 0x5F5B921: RTreeSplitNode (split_q.c:313)
 ==29334==    by 0x5F59D07: RTreeAddBranch (node.c:201)
 ==29334==    by 0x5F58B9E: RTreeInsertRect2 (index.c:121)
 ==29334==    by 0x5F58982: RTreeInsertRect2 (index.c:102)
 ==29334==    by 0x5F58D3F: RTreeInsertRect1 (index.c:162)
 ==29334==    by 0x5F58C25: RTreeInsertRect (index.c:141)
 ==29334==    by 0x5D4F9CC: dig_spidx_add_line (spindex.c:160)
 ==29334==    by 0x4E64254: Vect_build_sidx_from_topo (sindex.c:189)
 ==29334==    by 0x4E634C7: Vect_select_lines_by_box (select.c:53)
 ==29334==    by 0x403B95: main (main.c:534)
 ==29334==
 ==29334== 4,000 bytes in 1 blocks are still reachable in loss record 146
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D274: G__realloc (alloc.c:109)
 ==29334==    by 0x5D47974: dig_list_add (list.c:40)
 ==29334==    by 0x5D4FF50: _add_item (spindex.c:370)
 ==29334==    by 0x5F5885A: RTreeSearch (index.c:65)
 ==29334==    by 0x5F587A3: RTreeSearch (index.c:56)
 ==29334==    by 0x5D50168: dig_select_lines (spindex.c:467)
 ==29334==    by 0x4E63504: Vect_select_lines_by_box (select.c:60)
 ==29334==    by 0x403B95: main (main.c:534)
 ==29334==
 ==29334== 4,000 bytes in 1 blocks are still reachable in loss record 147
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D274: G__realloc (alloc.c:109)
 ==29334==    by 0x5D47974: dig_list_add (list.c:40)
 ==29334==    by 0x4E635A8: Vect_select_lines_by_box (select.c:71)
 ==29334==    by 0x403B95: main (main.c:534)
 ==29334==
 ==29334== 4,000 bytes in 50 blocks are still reachable in loss record 148
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D514BA: dig_alloc_line (struct_alloc.c:114)
 ==29334==    by 0x5D4B56A: dig_Rd_P_line (plus_struct.c:166)
 ==29334==    by 0x5D482D2: dig_load_plus (plus.c:302)
 ==29334==    by 0x4E5DF39: Vect_open_topo (open.c:751)
 ==29334==    by 0x4E5CC41: Vect__open_old (open.c:229)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403018: main (main.c:306)
 ==29334==
 ==29334== 4,000 bytes in 50 blocks are still reachable in loss record 149
 of 150
 ==29334==    at 0x4C242A3: malloc (vg_replace_malloc.c:195)
 ==29334==    by 0x529D162: G__malloc (alloc.c:41)
 ==29334==    by 0x5D514BA: dig_alloc_line (struct_alloc.c:114)
 ==29334==    by 0x5D4B56A: dig_Rd_P_line (plus_struct.c:166)
 ==29334==    by 0x5D482D2: dig_load_plus (plus.c:302)
 ==29334==    by 0x4E5DF39: Vect_open_topo (open.c:751)
 ==29334==    by 0x4E5CC41: Vect__open_old (open.c:229)
 ==29334==    by 0x4E5D3D9: Vect_open_old (open.c:415)
 ==29334==    by 0x403065: main (main.c:311)
 ==29334==
 ==29334== 240,000 bytes in 1 blocks are still reachable in loss record 150
 of 150
 ==29334==    at 0x4C2439D: realloc (vg_replace_malloc.c:476)
 ==29334==    by 0x529D28D: G__realloc (alloc.c:111)
 ==29334==    by 0x403F2E: main (main.c:577)
 ==29334==
 ==29334== LEAK SUMMARY:
 ==29334==    definitely lost: 10,048 bytes in 25 blocks
 ==29334==    indirectly lost: 0 bytes in 0 blocks
 ==29334==      possibly lost: 0 bytes in 0 blocks
 ==29334==    still reachable: 290,503 bytes in 689 blocks
 ==29334==         suppressed: 0 bytes in 0 blocks
 ==29334==
 ==29334== For counts of detected and suppressed errors, rerun with: -v
 ==29334== Use --track-origins=yes to see where uninitialised values come
 from
 ==29334== ERROR SUMMARY: 7225 errors from 28 contexts (suppressed: 4 from
 4)
 }}}

 With 300 random points it consumes more than 4GB RAM and needed to be
 killed then.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/14#comment:6>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list