Opened 8 years ago

Closed 8 years ago

#790 closed defect (fixed)

Memory leak in WKBReader.read?

Reported by: edzer Owned by: geos-devel@…
Priority: major Milestone: 3.5.1
Component: Default Version: 3.5.0
Severity: Unassigned Keywords:
Cc:

Description

When running the attached program with

valgrind --tool=memcheck --leak-check=full ./mem

it reports a memory leak. I see it pretty consistently with anything read this way with WKBReader.read().

Is this in my c++ code, or in geos?

Attachments (1)

mem.cpp (424 bytes ) - added by edzer 8 years ago.
cpp program that shows memory lead, compiled with g++ mem.cpp -lgeos-3.5.0

Download all attachments as: .zip

Change History (5)

by edzer, 8 years ago

Attachment: mem.cpp added

cpp program that shows memory lead, compiled with g++ mem.cpp -lgeos-3.5.0

comment:1 by strk, 8 years ago

Check test/unit/io/WKBReaderTest.cpp, is your test doing things differently ? Run with libtool --mode=execute valgrind ./geos_unit geos::io::WKBReader to ask valgrind about leaks generated there.

comment:2 by strk, 8 years ago

For the record, the valgrind report here:

==12044== HEAP SUMMARY:
==12044==     in use at exit: 72,704 bytes in 1 blocks
==12044==   total heap usage: 7,730 allocs, 7,729 frees, 557,680 bytes allocated
==12044== 
==12044== LEAK SUMMARY:
==12044==    definitely lost: 0 bytes in 0 blocks
==12044==    indirectly lost: 0 bytes in 0 blocks
==12044==      possibly lost: 0 bytes in 0 blocks
==12044==    still reachable: 72,704 bytes in 1 blocks
==12044==         suppressed: 0 bytes in 0 blocks
==12044== Rerun with --leak-check=full to see details of leaked memory
==12044== 
==12044== For counts of detected and suppressed errors, rerun with: -v
==12044== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

comment:3 by edzer, 8 years ago

I failed to use the auto_ptr:

    typedef std::auto_ptr<geos::geom::Geometry> GeomPtr;
    GeomPtr pt(r.read(sh));

solved my leak. Thanks a lot!

comment:4 by edzer, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.