Pixi.js: Memory leak in Graphics.clear

Created on 24 Mar 2017  路  9Comments  路  Source: pixijs/pixi.js

I investigated this and figured out a fix already; I just wanted to file an issue first before making a pull request.

Repro: this is caused by repeatedly clearing a Graphics object and then calling drawRect from WebGL. Rendering the Graphics object will call _renderSpriteRect, which makes a new Texture that never gets destroyed, so the TextureUvs object that gets created is never dereferenced.

JSFiddle repro link: http://jsfiddle.net/yabm091r/3/

Solution: add this code to Graphics.prototype.clear:

if (this._spriteRect) {
    this._spriteRect.destroy({texture: true});
    this._spriteRect = null;
}

P.S. here's a clip of me accidentally filing this bug with the title "tv" (my ctrl key wasn't working): https://clips.twitch.tv/ArbitraryConcernedHamCharlietheUnicorn

Most helpful comment

All 9 comments

That one is mine, investigating.

I've submitted a pull request here to make things easier: https://github.com/pixijs/pixi.js/pull/3870

White and Empty textures are supposed to be special, no destroy is needed for them. That is critical issue, I'll create PR for master branch.

And someone just wrote me in KOTLIN slack about twitch translation. Why in KOTLIN?

Timeline from my point of view:

https://www.twitch.tv/videos/130864061
05:28:00 - filling the issue
06:10:00 - submitting the issue
06:30:00 - I'm making alternative PR
06:41:00 - you can see our chat
and then we started a talk about a filters
"hackerham : OH GOD FILTERS !#@$%" - thats me
06:44:40 - the filter issue

@Adam13531 Can you confirm that the PR put in by @ivanpopelyshev fixed you issue? Thanks.

@englercj yes, I confirmed this on Friday. Thank you both for the quick response times!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lunabunn picture lunabunn  路  3Comments

madroneropaulo picture madroneropaulo  路  3Comments

neciszhang picture neciszhang  路  3Comments

distinctdan picture distinctdan  路  3Comments

YuryKuvetski picture YuryKuvetski  路  3Comments