kawabata Posted June 14, 2016 Share Posted June 14, 2016 Hi everybody, I would like to know how to unload a texture atlas (created with TexturePacker) and a spine file (created with Spine). I have loaded them directly using something like PIXI.loader .add(filename) .load(callback); But I cannot see any destroy method like the texture's destroy method. I have noticed that the loader has a "_image" resource associated with the json file and also some texture (and also something else) associated with the spine file. Should I write a destroy method by myself or is there a "standard" way to do this? I need to clear these resource types in order to free the GL memory. Thanks! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 14, 2016 Share Posted June 14, 2016 There are two ways 1. call destroy(true) method of a texture. Dont forget that texture is used by ALL spine instances of that model! 2. call pixi v4 "renderer.textureGC.run(); " method periodically. Or set GC to automatic. In any case, its better to destroy(true) spine object itself, otherwise vertex buffers allocated for Meshes will still be in memory. If you dont have meshes, it wont do anything. Quote Link to comment Share on other sites More sharing options...
kawabata Posted June 14, 2016 Author Share Posted June 14, 2016 Hi Ivan, thank you for your reply. 1. I have called destroy(true) on each texture of an atlas but I STILL see the json and json_image entries in PIXI.loader.resources. Is this fine? are they just placeholders and not real data? has the GL memory been released? 2. I don't know how to destroy a spine object. Let us say that I have loaded it via PIXI.loader .add("spineboy.json") .load(callback); spineBoy = new PIXI.spine.Spine(PIXI.loader.resources["spineboy.json"].spineData); How should I destroy the spine data and all the related resources? Thanks again very much! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 14, 2016 Share Posted June 14, 2016 1. yeah, destroy() doesnt remove it from loader. You have to deal with it for yourself. You can even use separate loader for each scene object and "forget" it when the scene ends 2. spineBoy.destroy(true); will get rid of all allocated Meshes. Of course, if you dont use meshes, there's nothing to destroy Imagine that you have number of levels. You can make a loader for each level, and just drop the links on it when level ends, it will work just fine. Just do it with Pixi v4, it has built-in garbage collector renderer.textureGC.mode = PIXI.GC_MODES.AUTO; And dont forget that there is old-style texture cache. you can just empty it after each loading, if you dont use fromImage() and that kind of methods. PIXI.utils.TextureCache = {}; PIXI.utils.BaseTextureCache = {}; Quote Link to comment Share on other sites More sharing options...
kawabata Posted June 14, 2016 Author Share Posted June 14, 2016 Thanks Ivan. 1. done! 2. I want to release the textures associated with spineboy.json. I guess it is something like: "spineboy.json_atlas_page_spineboy.png". Have I to find the right name of the asociated texture resource(s) and call destroy on them manually? Something related. Is there a tool to inspect the GL memory? I would double check that the textures have been released from the GL... Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 14, 2016 Share Posted June 14, 2016 I dont know how to inspect the GL memory, but PIXI GC has a list for it, though its not complete, it doesnt have RenderTextures in it. As for spineboy, well, according to 59-th line of atlasParser.js in pixi-spine gibhub : this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (res) { name of the resource is the same as you assigned to spineboy.json but with _atlas: loader.add('boy', 'spineboy.json'); loader.resources['boy_atlas']texture.destroy(true); //noname loader.add('spineboy.json'); loader.resources['spineboy.json_atlas']texture.destroy(true); Quote Link to comment Share on other sites More sharing options...
kawabata Posted June 15, 2016 Author Share Posted June 15, 2016 Perfect! Thanks for the incredible help! Ciao! ivan.popelyshev 1 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.