diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index fa0823acd1..02f6693217 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -46,7 +46,9 @@ #include "../ifcgeom/IfcRepresentationShapeItem.h" #include "../ifcgeom/IfcGeomShapeType.h" -#define NO_CACHE +// Define this in case you want to conserve memory usage at all cost. This has been +// benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47 +// #define NO_CACHE #ifdef NO_CACHE diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index 2d0cca7415..a536198c64 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -324,8 +324,12 @@ namespace IfcGeom { private: // Move to the next IfcRepresentation void _nextShape() { - if (done % 100 == 99) { - // kernel.purge_cache(); + // In order to conserve memory and reduce cache insertion times, the cache is + // cleared after an arbitary number of processed representations. This has been + // benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47 + static const int clear_interval = 64; + if (done % clear_interval == clear_interval - 1) { + kernel.purge_cache(); } ifcproducts.reset(); ++ representation_iterator;