From 4d8b81ba2f762ff68043ad69d42568d3ed32ca6d Mon Sep 17 00:00:00 2001 From: Nicolas Orchow Date: Wed, 1 Aug 2018 16:12:02 -0300 Subject: [PATCH 1/2] Clean Nucleus queue when removing an element This was generating a big memory leaks when creating and replacing several components permanently. --- cell.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cell.js b/cell.js index 995019fe..d153aa4a 100644 --- a/cell.js +++ b/cell.js @@ -286,6 +286,9 @@ return $node.Kill; }).forEach(function($node) { $parent.removeChild($node); + setTimeout(function(){ + Nucleus.disconnect($node); + }, 0); }); diff['+'].forEach(function(item) { var inheritance = $parent.Inheritance; @@ -513,6 +516,11 @@ $node.Dirty[key] = Gene.freeze($node.Genotype[key]); // stores the original value under "Dirty" } }, + disconnect: function($node) { + var index = Nucleus._queue.indexOf($node); + if (index !== -1) Nucleus._queue.splice(index, 1); + $node.childNodes.forEach(Nucleus.disconnect); + } }; var God = { /* From 5719eb5b17be155e35fdf555f1ee4703cdb8f011 Mon Sep 17 00:00:00 2001 From: Nicolas Orchow Date: Wed, 1 Aug 2018 16:40:23 -0300 Subject: [PATCH 2/2] Fix ESLint --- cell.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cell.js b/cell.js index d153aa4a..12b8d315 100644 --- a/cell.js +++ b/cell.js @@ -286,7 +286,7 @@ return $node.Kill; }).forEach(function($node) { $parent.removeChild($node); - setTimeout(function(){ + setTimeout(function() { Nucleus.disconnect($node); }, 0); }); @@ -520,7 +520,7 @@ var index = Nucleus._queue.indexOf($node); if (index !== -1) Nucleus._queue.splice(index, 1); $node.childNodes.forEach(Nucleus.disconnect); - } + }, }; var God = { /*