www.taras Posted January 20, 2020 Share Posted January 20, 2020 Hi , question about GC or how i can clean canvas2d object after use method generateCanvasTexture game use PIXI.WebGLRenderer - only PixiJs version 4.8.2 (this my pain, but i can`t up pixijs to v5) on class this.data:PIXI.Graphics this.view:PIXI.Sprite .... on sometimes i need redraw data on view this.texture =this.data.generateCanvasTexture(PIXI.SCALE_MODES.LINEAR,1); this.view.texture = this.texture; on next time try to clean this.texture, remove from PIXI.Texture.removeFromCache this.texture .destroy(true); delete this.texture ; but debug console in Safari (tab Canvas) show all Canvas wich created on method generateCanvasTexture, but they never destroyed on memory How i can do clean up memory on it? ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 20, 2020 Share Posted January 20, 2020 (edited) "this.texture.destroy(true)" should work. PixiJS removes lins from its cache, destroys WebGLTexture. If you see something lingering - please specify where exactly is that lingring, what is the path from root node. If you save a link to canvas somewhere - PixiJS wouldn't be able to "free" it. Its just not possible. Well, actually it is with "canvas.width=1; canvas.height=1;" but we dont have that code in our lib, we just nullify links to it and destroy webgl objects. Edited January 20, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
www.taras Posted January 20, 2020 Author Share Posted January 20, 2020 this.texture.baseTexture.source.width=1; this.texture.baseTexture.source.height=1; delete this.texture.baseTexture.source; thanks for prompt repl after implement this method Canvas2d memory is -64b(before 1.2 Mb), but object Canvas2D still present Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 20, 2020 Share Posted January 20, 2020 run a profiler , make memory dump - you should see nunmber of objects of every type - and when you click on any object , you can trace who exactly references it 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.