Opened 5 years ago

Closed 5 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 5 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)

Changed 5 years ago by edzer

Attachment: mem.cpp added

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

comment:1 Changed 5 years ago by strk

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 Changed 5 years ago by strk

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 Changed 5 years ago by edzer

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 Changed 5 years ago by edzer

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