Anonymous | Login | 2021-01-23 13:54 MSK | ![]() |
My View | View Issues | Change Log | Roadmap |
View Revisions: Issue #11789 | [ All Revisions ] [ Back to Issue ] | ||
Summary | 0011789: Several memory leaks in TopExp_Explorer methods Init and Clear. | ||
Revision | 2011-11-23 18:09 by szy | ||
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. ------------------------------------------------------ |
||
Revision | 2006-10-26 17:18 by szy | ||
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> To: Sergey ZERTCHANINOV <sergey.zertchaninov@opencascade.com> 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. ------------------------------------------------------ |
Copyright © 2000 - 2021 MantisBT Team |