Sat, 11/08/2008 - 20:43
Does anyone konw if there are known memory leaks with the OCC Mesh algorithms. The following code generates a steady consumption of memory which is only released when the application closes
for(int i=0;i
{
BRepBuilderAPI_MakePolygon w(gp_Pnt(0,0,0),gp_Pnt(0,100,0),gp_Pnt(20,100,0),gp_Pnt(20,0,0));
w.Close();
TopoDS_Wire wireShape( w.Wire());
BRepBuilderAPI_MakeFace faceBuilder(wireShape);
TopoDS_Face f( faceBuilder.Face());
BRepMesh_IncrementalMesh im(f,1);
BRepTools::Clean(f);
}
If you comment out the BRepMesh_IncrementalMesh line the memory consumtion flatlines. BRepTools::Clean seems to have no impact whatsoever on memory usage.
I am a real fan of OCC but this as I only really need mesh generation from a BRep model and I need to do this a lot of times, this problem is show stopper for me.
I have tried working through the source and wonder if it may be some form of cyclic referencing that is stopping the OCC memory manager from cleaning up. Does anyone have any ideas please?
Mon, 11/10/2008 - 13:01
OK, I think I have found the cause of the leak, it appears to be in
void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface)
at the line
BRepMesh_Classifier* classifier = new BRepMesh_Classifier(face, tolclass, internaledges, myvemap, structure, myumin, myumax, myvmin, myvmax);
The classifier pointer does not appear to be deleted, if a delete operator is added at the end of the classifier's scope then the memory leak dissappears.
My understanding of OCC is not good enough to let me know if this is a sensible fix, I assume there was a good reason to create a pointer to a BRepMesh_Classifier in this way, maybe it is passed out and used somewhere else.
I would really appreciate someone with a strong knowledge of OCC to help me know if this might be the solution to the memory leak problem that I am observing
Mon, 11/10/2008 - 13:16
Hi Steve,
I think you have found and fixed a real bug, as nowhere this pointer is passed in the code outside of this class.
Mon, 11/10/2008 - 15:48
I'm new to the OpenCascade forum, if this is a bug how do we notify OCT or do they just pick it up from here?
Mon, 11/10/2008 - 16:05
Nobody knows how they do, but some fixes posted here earlier are already in the source code.
Tue, 11/11/2008 - 01:27
Hi Steve,
the classifier seems to be deleted a few lines below (line 496 in BRepMesh_FastDiscret)
if (myfacestate != BRepMesh_NoError && myfacestate != BRepMesh_ReMesh)
{
mynottriangulated.Append(face);
delete classifier;
}
You should trace in debugger to see whether or not the classifier is deleted before end of the function.
Regards.
Tue, 11/11/2008 - 09:58
Dear Mr. Lockley,
Thank you for reporting this problem in Open CASCADE Technology and your deep investigation!
We are pleased to inform you that the problem you reported has been registered as bug with reference number OCC20627 "Memory leaks in BRepMesh".
Please note that you will be able to track fixing on that bug by consulting the Release Notes of Open CASCADE Technology that are published on our web site at http://www.opencascade.org/getocc/whatsnew.
Yours sincerely,
Open CASCADE Support Team