From 8bd305270a83f8794859108b3e8eb200971a7521 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 8 Aug 2016 13:38:01 -0400 Subject: Avoid repopulating dead nodes; otherwise, we might wind up killing a node multiple times, screwing up the free list of available closure IDs (with duplicates), so that the same ID gets allocated for multiple functions later --- lib/js/urweb.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 68e7979d..b871b8e5 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -731,6 +731,8 @@ function flattenLocal(s) { // Dynamic tree management function populate(node) { + if (node.dead) return; + var s = node.signal; var oldSources = node.sources; try { -- cgit v1.2.3 From 3bcc7ed859aecb758742b0cf23cae98214938012 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 8 Aug 2016 13:53:17 -0400 Subject: Remove a check that was actually always passing because it was on the wrong object; this helps explain why the last change was necessary --- lib/js/urweb.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index b871b8e5..95fd6756 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -762,8 +762,7 @@ function sv(s, v) { s.data = v; for (var ls = s.dyns; ls; ls = ls.next) - if (!ls.dead) - populate(ls.data); + populate(ls.data); } } function sg(s) { -- cgit v1.2.3 From 0b38f30883241b7dc45f8e2b8ff1a9c52a8b1536 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 24 Aug 2016 12:14:14 -0400 Subject: Plug a reactive-DOM memory leak (thanks to Saulo Araujo for spotting the problem and proposing a slightly different fix) --- lib/js/urweb.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 95fd6756..222a8322 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1100,12 +1100,18 @@ function active(s) { function input(x, s, recreate, type, name) { if (name) x.name = name; if (type) x.type = type; - x.dead = false; - x.signal = ss(s); - x.sources = null; - x.recreate = recreate(x); addNode(x); - populate(x); + + var sc = document.createElement("script"); + sc.dead = false; + sc.signal = ss(s); + sc.sources = null; + sc.recreate = recreate(x); + + if (x.parentNode) + x.parentNode.insertBefore(sc, x); + + populate(sc); return x; } -- cgit v1.2.3