From e1aa2bfaca413f4b2ada010c6b7bfb4bb37df3c1 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 10 Jan 2023 21:28:35 -0500 Subject: [PATCH] test free mem on slice --- notes.md | 1 + src/geo/polygon.js | 12 ++++++++++++ src/geo/slicer.js | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/notes.md b/notes.md index 51712c50..4c7f9c32 100644 --- a/notes.md +++ b/notes.md @@ -76,6 +76,7 @@ * `B` need to force cut line at synthetic z bottom (midlines, etc) * `B` contour does not honor clip to stock +* `F` get gcode coordinates off a part with point/click or hover? * `F` include tools in default devices (Carvera) * `F` add `match faces` option in `outline` operation * `F` add {progress} substitution and maybe {time-remaining} if can be calc'd diff --git a/src/geo/polygon.js b/src/geo/polygon.js index d6be990c..9b92a220 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -1285,6 +1285,18 @@ class Polygon { return this; } + freeParentRefs() { + if (this.inner && this.inner.length > 0) { + for (let inner of this.inner) { + inner.freeParentRefs(); + delete inner.parent; + } + } + for (let p of this.points) { + delete p.poly; + } + } + newUndeleted() { let poly = newPolygon(); this.forEachPoint(p => { diff --git a/src/geo/slicer.js b/src/geo/slicer.js index 88bbaf9e..4ca3561c 100644 --- a/src/geo/slicer.js +++ b/src/geo/slicer.js @@ -402,6 +402,23 @@ async function sliceZ(z, points, options = {}) { if (fn) fn(rval, options); } + // free objects to be re-claimed and reduce memory pressure + if (false) { + delete rval.groups + delete rval.lines + delete rval.clip.m_AllPolys + + for (let top of rval.tops) { + top.poly.freeParentRefs(); + top.simple.freeParentRefs(); + for (let shell of top.shells) shell.freeParentRefs(); + for (let fillo of top.fill_off) fillo.freeParentRefs(); + for (let last of top.last) last.freeParentRefs(); + } + + for (let clip of rval.clip) clip.freeParentRefs(); + } + if (each) each(rval); return rval; }