Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#198 closed defect (fixed)

Missing named destructor for PreparedGeometry

Reported by: mloskot Owned by: mloskot
Priority: critical Milestone: 3.1.0
Component: Core Version: main
Severity: Significant Keywords: PreparedGeometry destructor
Cc:

Description

In the wake of today thread on the mailing list: How to destroy PreparedGeometry object?, I'm reporting the lack of named destructor for PreparedGeometry as a bug.

I'm going to implement it as new static method:

static void PreparedGeometryFactory::destroy(const PreparedGeometry* geom)
{
   delete geom;
}

Change History (6)

comment:1 by mloskot, 16 years ago

Owner: set to mloskot
Status: newassigned

comment:2 by mloskot, 16 years ago

The memory leak can be reproduced usign newly submitted PreparedGeometryFactoryTest (r2149) using this command:

$ libtool --mode=execute valgrind --tool=memcheck --leak-check=yes ./geos_unit geos::geom::prep::PreparedGeometryFactory

==7567== Memcheck, a memory error detector.
==7567== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==7567== Using LibVEX rev 1658, a library for dynamic binary translation.
==7567== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==7567== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==7567== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==7567== For more details, rerun with: -v
==7567== 
===============================
  GEOS Test Suite Application
===============================
 
geos::geom::prep::PreparedGeometryFactory: ..... 5
 
Tests summary:
 - passed: 5
==7567== 
==7567== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 21 from 1)
==7567== malloc/free: in use at exit: 40 bytes in 2 blocks.
==7567== malloc/free: 2,517 allocs, 2,515 frees, 77,521 bytes allocated.
==7567== For counts of detected errors, rerun with: -v
==7567== searching for pointers to 2 not-freed blocks.
==7567== checked 145,724 bytes.
==7567== 
==7567== 40 bytes in 2 blocks are definitely lost in loss record 1 of 1
==7567==    at 0x4021DC5: operator new(unsigned) (vg_replace_malloc.c:163)
==7567==    by 0x40B7ADB: geos::geom::prep::PreparedGeometryFactory::create(geos::geom::Geometry const*) const (PreparedGeometryFactory.cpp:62)
==7567==    by 0x80F4A8A: void tut::test_object<tut::test_preparedgeometryfactory_data>::test<4>() (PreparedGeometryFactory.h:62)
==7567==    by 0x80F7FCE: tut::test_group<tut::test_preparedgeometryfactory_data, 50>::run_test_(std::_Rb_tree_iterator<std::pair<int const, void (tut::test_object<tut::test_preparedgeometryfactory_data>::*)()> > const&, tut::test_group<tut::test_preparedgeometryfactory_data, 50>::safe_holder<tut::test_object<tut::test_preparedgeometryfactory_data> >&) (tut.h:973)
==7567==    by 0x80F8DFB: tut::test_group<tut::test_preparedgeometryfactory_data, 50>::run_next() (tut.h:862)
==7567==    by 0x8051278: main (tut.h:452)
==7567== 
==7567== LEAK SUMMARY:
==7567==    definitely lost: 40 bytes in 2 blocks.
==7567==      possibly lost: 0 bytes in 0 blocks.
==7567==    still reachable: 0 bytes in 0 blocks.
==7567==         suppressed: 0 bytes in 0 blocks.
==7567== Reachable blocks (those to which a pointer was found) are not shown.
==7567== To see them, rerun with: --show-reachable=yes

comment:3 by mloskot, 16 years ago

Resolution: fixed
Severity: UnassignedSignificant
Status: assignedclosed

Fixed in trunk (r2151)

After this patch, the test does not report any memory leaks for PreparedGeometry:

$ libtool --mode=execute valgrind --tool=memcheck --leak-check=yes ./geos_unit geos::geom::prep::PreparedGeometryFactory
==8147== Memcheck, a memory error detector.
==8147== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==8147== Using LibVEX rev 1658, a library for dynamic binary translation.
==8147== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==8147== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework.
==8147== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==8147== For more details, rerun with: -v
==8147== 
===============================
  GEOS Test Suite Application
===============================
 
geos::geom::prep::PreparedGeometryFactory: ..... 5
 
 
Tests summary:
 - passed: 5
==8147== 
==8147== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 21 from 1)
==8147== malloc/free: in use at exit: 0 bytes in 0 blocks.
==8147== malloc/free: 2,517 allocs, 2,517 frees, 77,521 bytes allocated.
==8147== For counts of detected errors, rerun with: -v
==8147== All heap blocks were freed -- no leaks are possible.

comment:4 by mloskot, 16 years ago

Small but very important fix missing added to trunk (r2152)

comment:5 by (none), 15 years ago

Milestone: 3.1.0

Milestone 3.1.0 deleted

comment:6 by pramsey, 15 years ago

Milestone: 3.1.0
Note: See TracTickets for help on using tickets.