codart Posted May 4, 2018 Share Posted May 4, 2018 I have implemented a music visualizer here: https://codesandbox.io/s/qz22m03nw4 I created a cool trail effect in "circle.js". But after a while, the memory leak so bad. Can you point out what wrong with my solution? Quote Link to comment Share on other sites More sharing options...
jonforum Posted May 4, 2018 Share Posted May 4, 2018 with the new chrome monitor , it can help you to find memory leak. Can you share a screen with your issue ? memory never empties? or where from what time does it increase radically? Quote Link to comment Share on other sites More sharing options...
codart Posted May 4, 2018 Author Share Posted May 4, 2018 2 hours ago, jonforum said: with the new chrome monitor , it can help you to find memory leak. Can you share a screen with your issue ? memory never empties? or where from what time does it increase radically? Hi! I know exactly where the leak happen. You can open the sandbox, my app run within it. Please pick a mp3 file then see the effect as below: This is the snippet of code which I pretty sure cause the memory leak: onTick(delta) { const data = this.visualizer.data; const { center, radius, inscrement } = this.caculatedFactors; // this.periodicRad += this.periodicRadInscreament; data.forEach((value, i) => { const circle = this.circles[i]; const radian = inscrement * i; circle.x = center.x + (radius + value) * Math.cos(radian); circle.y = center.y + (radius + value) * Math.sin(radian); }); if (!this.previousGroupTexture) { this.previousGroupTexture = this.app.renderer.generateTexture(this.group); } // if (this.app.ticker.elapsedMS % 100 == 0) { const temp = this.effectSprite.texture; this.effectSprite.texture = this.previousGroupTexture; this.group.alpha = 0.9; this.previousGroupTexture = this.app.renderer.generateTexture(this.group); this.group.alpha = 1; temp.destroy(); // } // } } Quote Link to comment Share on other sites More sharing options...
Exca Posted May 4, 2018 Share Posted May 4, 2018 Instead of generating new texture on each tick you should use single texture and redraw to that. Quote Link to comment Share on other sites More sharing options...
jonforum Posted May 4, 2018 Share Posted May 4, 2018 am sorry , i don have mp3 on my pc. But like say upper, you can try double check all textures PIXI.utils.TextureCache Quote Link to comment Share on other sites More sharing options...
botmaster Posted May 4, 2018 Share Posted May 4, 2018 1 hour ago, Exca said: Instead of generating new texture on each tick you should use single texture and redraw to that. yeah all that texture creation seems suspicious. 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.