Skip to content

Commit

Permalink
fix(swingset): disable GC for now
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
warner committed Apr 23, 2021
1 parent 6309e5f commit e93066f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e93066f

Please sign in to comment.