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 myStack[i].~TopoDS_Iterator();
myTop = -1;
hasMore = Standard_False;
if(myTop > 0)
for(int i = 1; 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: