I thought I should mention that Director class as I know it and use it doesn’t cause memory leak. If I’m not mistaken, the issue is more to do with the usage of module(…, package.seeall) in each lua file.
After investigating this and following discussions relating to memory leak and how-to-properly-modularize, I came to a conclusion that if I open a module that starts with module(…, package.seeall), I need to un-require it.
I’m a too much of a newbie (in terms of programing/coding) to understand the fine workings behind it, but because I happen to use Spriteloq and it also comes with utility tool that has unrequire function, all I do is, when I changescene, I call unrequire.
So, when I am on level1.lua, and is ready to change scene to level2.lua, I include the following lines:
[lua]director:changeScene(“level2”, “flip”);
unrequire(“level1”);[/lua]
This pretty much made the memory management of my game sound and healthy, and I don’t feel I need to worry about it. (Please note, I am a customer of Spriteloq, and I’m a very happy customer at that, and I have no trouble recommending highly of the product, but I do not work for Spriteloq or have any relationship with them, other than the fact I bought it and have benefited from it.)
Director manages texture memory incredibly well. Whether I use unrequire or not, it made no difference in terms of texture memory management. In my project, director always kept the size of texture memory consistent (i.e., I have not seen any leakage associated with texture memory).
So… I think if you are concerned over memory leakage associated with modular structure of your project, you may want to find the answers to the memory leakage issue associated with module(…, package.seeall) function and find the way to minimize the problem (rather than worrying about Director class as being the cause of it – because, honestly, Director class isn’t the cause of it, and it is too awesome a class not to use, and honestly, because I use Director in every single scene, I don’t bother localizing Director, but I require it in as global module in main.lua and never even think about unrequiring it.)
I hope I haven’t confused anyone or caused any additional headache, but I thought I should mention what I thought of Director (being a staunch fan of this class).
P.S. If I’m mistaken, please let me know. I’m always interested in figuring out how I may make my project completely and utterly memory-leak-free.
[import]uid: 67217 topic_id: 15868 reply_id: 59548[/import]