Drop Image data once rendered
Helps the browser to free up the memory right away, rather than waiting until some later cleanup process. At least Firefox can start consuming gigabytes of memory without this.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user