bubamara Posted August 1, 2013 Share Posted August 1, 2013 Hi, to prevent memory leak, I want to delete unused texture. What is the proper way to do it?Let's say I created texture : var button = PIXI.Texture.fromCanvas(canvas); Later in the code i want to do something like this : button.destroy(); // really delete texture from memorybutton = PIXI.Texture.fromCanvas(canvas); // newly created texture Thanks in advance,-bubamara Quote Link to comment Share on other sites More sharing options...
xerver Posted August 2, 2013 Share Posted August 2, 2013 PIXI.Texture has a destroy method that will remove it from the WebGL memory (source: https://github.com/GoodBoyDigital/pixi.js/blob/master/src/pixi/textures/Texture.js#L78). You probably want this:var button = PIXI.Texture.fromCanvas(canvas);button.destroy(true); // delete this texture, and the base texture Quote Link to comment Share on other sites More sharing options...
bubamara Posted August 2, 2013 Author Share Posted August 2, 2013 yes exactly, thank you EDIT: i just tried it on bunny example-1 with no success. function rem() { texture.destroy(true);} i get message : Uncaught TypeError: Object function (width, height, view, transparent) {// do a catch.. only 1 webGL renderer.....} has no method 'destroyTexture' any idea? Quote Link to comment Share on other sites More sharing options...
bubamara Posted August 3, 2013 Author Share Posted August 3, 2013 have someone idea, what is causing error mentioned above? abything that i'm doing wrong?also, shouldn't be here : PIXI.Text.prototype.destroy = function(destroyTexture){ if(destroyTexture) { this.texture.destroy(); }}; this.texture.destroy(true); ?? Quote Link to comment Share on other sites More sharing options...
Mat Groves Posted August 3, 2013 Share Posted August 3, 2013 I will look into that for you as it should not be throwing errors :/ Thanks for the heads up! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.