From e93066f7b9bebecced901fcb7cbf5d445f78dcf9 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 20 Apr 2021 18:39:34 -0700 Subject: [PATCH] fix(swingset): disable GC for now Until #2724 is implemented, we cannot safely allow Presences to be collected, because we have WeakMaps that think they'll stick around. Disable collection by putting all imports into the (strong) `exported` Set. We'll remove this when WeakMap/WeakSet is updated to know the difference between non-REACHABLE and non-RECOGNIZABLE. --- packages/SwingSet/src/kernel/liveSlots.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/SwingSet/src/kernel/liveSlots.js b/packages/SwingSet/src/kernel/liveSlots.js index 6f192f40ba2..f33a663a942 100644 --- a/packages/SwingSet/src/kernel/liveSlots.js +++ b/packages/SwingSet/src/kernel/liveSlots.js @@ -444,6 +444,12 @@ function build( assert.fail(X`unrecognized slot type '${type}'`); } slotToVal.set(slot, new WeakRef(val)); + // TODO: until #2724 is implemented, we cannot actually release + // Presences, else WeakMaps would forget their entries. We disable GC + // by stashing everything in the (strong) `exported` Set. Note that + // test-liveslots.js test('dropImports') passes despite this, because + // it uses a fake WeakRef that doesn't care about the strong reference. + exported.add(val); if (type === 'object' || type === 'device') { // we don't dropImports on promises, to avoid interaction with retire droppedRegistry.register(val, slot);