diff --git a/core/display.js b/core/display.js index ef42ac66..4efd6f4b 100644 --- a/core/display.js +++ b/core/display.js @@ -521,6 +521,9 @@ export default class Display { return; } this.drawImage(a.img, a.x, a.y); + // This helps the browser free the memory right + // away, rather than ballooning + a.img.src = ""; } else { a.img._noVNCDisplay = this; a.img.addEventListener('load', this._resumeRenderQ); diff --git a/tests/test.display.js b/tests/test.display.js index 5844ce17..528b1906 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -384,10 +384,11 @@ describe('Display/Canvas helper', function () { }); it('should draw an image from an image object on type "img" (if complete)', function () { + const img = { complete: true }; display.drawImage = sinon.spy(); - display._renderQPush({ type: 'img', x: 3, y: 4, img: { complete: true } }); + display._renderQPush({ type: 'img', x: 3, y: 4, img: img }); expect(display.drawImage).to.have.been.calledOnce; - expect(display.drawImage).to.have.been.calledWith({ complete: true }, 3, 4); + expect(display.drawImage).to.have.been.calledWith(img, 3, 4); }); }); });