From a1d584796a2691989f38ab2ab68c9e566923f51a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 1 May 2016 20:38:10 +0200 Subject: [PATCH] Set reasonable defaults for caching behavior --- src/ifcgeom/IfcGeom.h | 4 +++- src/ifcgeom/IfcGeomIterator.h | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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;