Out of Memory, help with better management?

I'm currently trying to run a program that can fuse about 5000 solids and output them to an stl file. Currently the most I have gotten to work is 200 solids. I tried running the program on a set of 450 solids last night, but when I woke up I found that I had run out of memory. I am reading all of the TopoDS_Shape's into a build queue, and then taking the first two solids from the front of the queue, fusing them, and pushing them to the back of the queue. In this way I end up with a heap-like system of build up. I fear that I might not be freeing the memory from my BRepAlgoAPI_Fuse operations correctly. Here is the loop that fuse's the objects in the build queue:

// Construct the solid from the build queue.
TopoDS_Shape Alpha, Beta;
while (build_queue.size() > 1)
Alpha = build_queue.front();
Beta = build_queue.front();

// Fetching start time for union.

BRepAlgoAPI_Fuse boolOpUnion(Alpha, Beta);

if (boolOpUnion.IsDone())

if (boolOpUnion.IsDeleted())

// Fetching end time for union.

cout cout }

Is there anyway I can manually tidy up my memory usage after each iteration of the loop?

Rob Bachrach's picture

There is a known memory leak in the BRepAlgoAPI classes. Based on the recent release notes, it looks like this may have been fixed in the latest maintenance release. I vaguely remember that someone may have posted a patch to this forum, but I don't have time to search for it. Sorry.

Michael Cook's picture

Alright, I google searched the forum but I didn't find anything. Do you remember the name of hte post that the problem may have appeared in? I am going to start searching manally, but if anyone knows where this patch was listed I would really appreciate it.

Also, I did read the release note for OpenCASCADE v5.2.4, however, I wasn't clear as to where it was available. On the download page, the link is listed just as v5.2.

Rob Bachrach's picture

It's possible I am wrong about the patch, but you should find the bug report. Maybe there's something in that thread.

Unfortunately, maintenance releases are not available to the Open Source community. They are only released to paying customers. If you are one, you should get instructions on the download. If not, the rest of us peons have to wait for the next public release (whenever that may be).

Michael Cook's picture

Alright, it is as I feared then :-) I'll start looking for that bug report, where are they listed?

Rob Bachrach's picture

If there was a patch posted, it should be in this forum. Click on the link for the forum thread in this email and use the Search selection on the left menu. You might have to sort through a lot.

The bug list is no longer publically available.

Michael Cook's picture

That seems kind of rediculous that the bug list isn't publicly available, but who am I to judge hehe.

Thanks for your help Rob.