XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

Rapid memory leak caused by wall, was fine in xbim 4.

Open ManIkWeet opened this issue 3 years ago • 1 comments

A customer sent us a model that didn't load and eventually crashed the computer. After a bit of research it appeared the model worked fine in XbimXplorer, which is still version 4. Running the XbimXplorer from the GitHub repository, which is version 5, caused the same memory leak/crash behavior. I managed to isolate, using the stripping tool, that the issue is caused by a single wall.

Assemblies and versions affected:

*Which assemblies/packages and their versions are known to be affected. E.g. Xbim.Essentials 5.0.200 Xbim.Common 5.1.0.0 5.1.323.0 Xbim.Geometry.Engine.Interop 5.1.0.0 5.1.403.0 Xbim.Ifc 5.1.0.0 5.1.323.0 Xbim.Ifc2x3 5.1.0.0 5.1.323.0 Xbim.Ifc4 5.1.0.0 5.1.323.0 Xbim.IO.Esent 5.1.0.0 5.1.0.322 Xbim.IO.MemoryModel 5.1.0.0 5.1.323.0 Xbim.ModelGeometry.Scene 5.1.0.1 5.1.403.0 Xbim.Presentation 5.1.0.0 5.1.0.0 Xbim.Tessellator 5.1.0.0 5.1.323.0

Steps (or code) to reproduce the issue:

Load the provided file in the latest version of XbimXplorer, keep taskmanager ready to kill the application. The memory will start leaking when "Building Elements". Using the debugger to pause execution does not pause the memory leak, indicating it might happen in native code.

Minimal file to reproduce the issue:

memory leak wall that worked in xbim 4.zip

Expected behavior:

I expect the application to not crash/run out of memory. Either by having a slightly incorrect representation of the wall, or giving some kind of warning and ignoring the wall. Preferably, if possible, the representation of the wall, as it was in version 4.

Actual behavior or exception details:

Memory usage rapidly increases (to my maximum of 30GB) and grinds the whole computer to a halt.

Additional Details

My guess is some issue with boolean operations used in the wall, it appears to have quite a few of them.

ManIkWeet avatar Apr 21 '21 09:04 ManIkWeet

With default model precision, It seems that in https://github.com/xBimTeam/XbimGeometry/blob/master/Xbim.Geometry.Engine/XbimSolidSet.cpp #597

			`try
			{
				//sometimes unifier crashes
				unifier.Build();
				result =unifier.Shape();
			}`

The 'unifier.Build()' never finished, along with growing memory usage.

But if use higher model precision like this:

            model.ModelFactors.Precision = 1.0e-6;
            model.ModelFactors.PrecisionBoolean = 1.0e-6;

It works with this result:

image

crazyrainman avatar Apr 24 '21 10:04 crazyrainman