Drop a canvas's backing store now, rather than at the next collection.
A capture allocates two of these — the crop at up to 508x1080 and the thumbnail — and a
2D canvas's backing store is four bytes a pixel, so one photo is a little over 2MB of
bitmap that stays resident until the collector decides otherwise. A player taking fifty
photos in a sitting is a hundred megabytes of it, in a CEF instance shared with the
game.
Resizing to 0 is the documented way to release it immediately; dropping the reference
alone is not, because the backing store is not on the JS heap. Defensive rather than a
measured fix — the accumulation is inferred from how canvases are allocated here, not
observed in game, and it costs two assignments to rule out.
Drop a canvas's backing store now, rather than at the next collection.
A capture allocates two of these — the crop at up to 508x1080 and the thumbnail — and a 2D canvas's backing store is four bytes a pixel, so one photo is a little over 2MB of bitmap that stays resident until the collector decides otherwise. A player taking fifty photos in a sitting is a hundred megabytes of it, in a CEF instance shared with the game.
Resizing to 0 is the documented way to release it immediately; dropping the reference alone is not, because the backing store is not on the JS heap. Defensive rather than a measured fix — the accumulation is inferred from how canvases are allocated here, not observed in game, and it costs two assignments to rule out.