Jump to content

Does destroying animated sprite take time for garbage collection?


Sahil
 Share

Recommended Posts

I am using 150-250 sprites of size 1920x1080 in animated sprite. There are four stages, whenever I don't need a stage I destroy animated sprite and base textures for it. Memory does get released after some time but I was curious if I am doing something wrong apart from using too large and too many images. Following is how I am destroying everything,

stage.removeChild(videoSprite);

videoSprite.destroy({
 children: true,
 texture: true,
 baseTexture: true
});
videoSprite = null;

for (var i = 0; i < textureArray.length; i++) {
 var texture = textureArray[i];
 texture.destroy(true);                
}

textureArray = null;
PIXI.utils.clearTextureCache();

Anything I am doing wrong or can do to release memory faster?

Edited by Sahil
Link to comment
Share on other sites

"texture.destroy(true)" should work, yep.

In ase you forgot to free something, pixi will automatically remove object from videomemory in a minute or two. You can place breakpoint here or add "console.log" to see if GC is triggered: https://github.com/pixijs/pixi.js/blob/dev/packages/core/src/textures/TextureGCSystem.js#L103

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...