MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011789Community[OCCT] OCCT:Modeling Algorithmspublic2006-03-03 11:332011-11-25 15:06
Reportermkv 
Assigned Togka 
PrioritynormalSeveritytrivial 
StatusclosedResolutionfixed 
PlatformOSAllOS Version
Product Version 
Target VersionFixed in Version[OCCT] 6.1.1 
Summary0011789: Several memory leaks in TopExp_Explorer methods Init and Clear.
Description-------- Original Message --------
 Subject: [OCC Forum] Memory leak in TopExp_Explorer
 Date: Mon, 16 Jan 2006 15:40:02 +0100
 From: Christian R. Krug <Christian.Krug@pace.de>



 This message was sent from www.opencascade.org
 <http://www.opencascade.org> [^] forum.
 http://www.opencascade.org/org/forum/thread_9297/ [^]
 ------------------------------------------------------


 Hi Everybody !


 There is a severe memory leak in TopExp_Explorer methods Init and Clear.

 If the member field myTop is greater -1, resp. 0, the destructor for
 all TopoDS_Iterator's on the current stack is never called.

 For example in BRepLib_FindSurface the Init method for the same
 TopExp_Explorer is called repeatedly. This has the effect that the
 reference counter for the first edge of a given face is continuously
 increasing, and its memory can never be freed.

 I suspect, that one of the previous maintainance releases already
 incorporates a fix for this leakage. But for all non-commercial users
 of Open CASCADE, I give an outline of the solution to this problem.

 Modify Init and Clear methods so that the destructors get called:

 void TopExp_Explorer::Init(const TopoDS_Shape& S,
                 const TopAbs_ShapeEnum ToFind,
                 const TopAbs_ShapeEnum ToAvoid)
 {
      if(myTop >= 0)
           for(int i = 0; i <= myTop; ++i)
                myStack[i].~TopoDS_Iterator();
      myTop = -1;
      
      [...]
 }

 void TopExp_Explorer::Clear()
 {
      hasMore = Standard_False;
      if(myTop > 0)
           for(int i = 1; i <= myTop; ++i)
                myStack[i].~TopoDS_Iterator();
      myTop = 0;
 }

 Both forms of the TopExp_Explorer constructor have to initialize the
 member fields:

      : myStack(0L), myTop(-1), mySizeOfStack(theStackSize)

 and ReInit needs only call Init:

 void TopExp_Explorer::ReInit()
 {
 Init(myShape,toFind,toAvoid);
 }

 Regards, Kris.

 ------------------------------------------------------
Additional information
and documentation updates
Documentation remark, added by gka 2006-08-25 10:28:55:

Improvements:
Added code removing previously created objects having type TopoDS_Iterator in
the methods Init() and Clear().
TagsNo tags attached.
Test case number
Attached Filesgz file icon OCC11789-mkv-v1.tar.gz (213,072 bytes) 2006-03-06 14:46
gz file icon OCC11789-mkv-v2.tar.gz (213,085 bytes) 2006-03-10 15:25
gz file icon Bug11789.tar.gz (1,820 bytes) 2006-08-25 10:23

- Relationships

-  Notes
(0011305)
aki (developer)
2006-03-07 12:21

Much regress in KAS:dev:OCC11789-opt regarding to Products.
(0011309)
aki (developer)
2006-03-22 17:35

No regress in KAS:dev:OCC11789-opt regarding to Products on sun.

- Issue History
Date Modified Username Field Change
2006-03-06 16:48 mkv CC => mkv
2006-03-09 16:17 bugmaster groupset1 => 4096
2006-03-09 16:17 bugmaster Customer => Community
2006-08-22 17:14 bugmaster Assigned To bugmaster => gka
2006-08-22 17:14 bugmaster Status new => assigned
2006-08-25 12:23 gka Status assigned => resolved
2006-08-25 19:28 mkv Status resolved => tested
2006-09-06 09:43 bugmaster Status tested => verified
2006-10-26 19:18 bugmaster Status verified => closed
2006-10-26 19:18 bugmaster Resolution @0@ => fixed
2011-08-02 11:31 bugmaster Category OCCT:MOA => OCCT:Modeling Algorithms
2011-11-23 18:09 szy Description Updated View Revisions
2011-11-23 18:09 szy Additional Information Updated View Revisions
2011-11-25 15:06 szy Summary There is a severe memory leak in TopExp_Explorer methods Init and Clear. => Several memory leaks in TopExp_Explorer methods Init and Clear.


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker