test free mem on slice

This commit is contained in:
Stewart Allen 2023-01-10 21:28:35 -05:00
commit e1aa2bfaca
3 changed files with 30 additions and 0 deletions

View file

@ -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

View file

@ -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 => {

View file

@ -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;
}