Merge pull request #4959 from nnethercote/zero-cache-canvases

Zero the height and width of cached canvases before deleting them.
This commit is contained in:
Yury Delendik 2014-06-17 08:26:04 -05:00
commit 11302f09a4

View File

@ -179,7 +179,14 @@ var CachedCanvases = (function CachedCanvasesClosure() {
return canvasEntry; return canvasEntry;
}, },
clear: function () { clear: function () {
cache = {}; for (var id in cache) {
var canvasEntry = cache[id];
// Zeroing the width and height causes Firefox to release graphics
// resources immediately, which can greatly reduce memory consumption.
canvasEntry.canvas.width = 0;
canvasEntry.canvas.height = 0;
delete cache[id];
}
} }
}; };
})(); })();