MantisBT - Community
View Issue Details
0011789Community[OCCT] OCCT:Modeling Algorithmspublic2006-03-03 11:332011-11-25 15:06
mkv 
gka 
normaltrivial 
closedfixed 
All
 
[OCCT] 6.1.1 
0011789: Several memory leaks in TopExp_Explorer methods Init and Clear.
-------- 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.

 ------------------------------------------------------
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().
No tags attached.
gz OCC11789-mkv-v1.tar.gz (213,072) 2006-03-06 14:46
https://tracker.dev.opencascade.org/
gz OCC11789-mkv-v2.tar.gz (213,085) 2006-03-10 15:25
https://tracker.dev.opencascade.org/
gz Bug11789.tar.gz (1,820) 2006-08-25 10:23
https://tracker.dev.opencascade.org/
Issue History
2006-03-06 16:48mkvCC => mkv
2006-03-09 16:17bugmastergroupset1 => 4096
2006-03-09 16:17bugmasterCustomer => Community
2006-08-22 17:14bugmasterAssigned Tobugmaster => gka
2006-08-22 17:14bugmasterStatusnew => assigned
2006-08-25 12:23gkaStatusassigned => resolved
2006-08-25 19:28mkvStatusresolved => tested
2006-09-06 09:43bugmasterStatustested => verified
2006-10-26 19:18bugmasterStatusverified => closed
2006-10-26 19:18bugmasterResolution@0@ => fixed
2011-08-02 11:31bugmasterCategoryOCCT:MOA => OCCT:Modeling Algorithms
2011-11-23 18:09szyDescription Updatedbug_revision_view_page.php?rev_id=948#r948
2011-11-23 18:09szyAdditional Information Updatedbug_revision_view_page.php?rev_id=950#r950
2011-11-25 15:06szySummaryThere is a severe memory leak in TopExp_Explorer methods Init and Clear. => Several memory leaks in TopExp_Explorer methods Init and Clear.

Notes
(0011305)
aki   
2006-03-07 12:21   
Much regress in KAS:dev:OCC11789-opt regarding to Products.
(0011309)
aki   
2006-03-22 17:35   
No regress in KAS:dev:OCC11789-opt regarding to Products on sun.