Clear module vs. clear context
Hi,
currently I am only using one context and one module. Suppose I want to load another script-file, for example because a new scene is loaded, what is the right way to clear up resources?
Is it enough if I release the module and call the garbagecollector? Or do I have to release the context as well? Or should I rather re-use the module for the new script file?
You don't have to release the module, you can just add new script sections to it and then call build on it. This will automatically release the previous resources held in the GC. The same for the context, as it is reused it will release the previous resources.
The garbage collector should preferably be invoked periodically, so that it can collect garbage before too much is accumulated. It's recommended to run it incrementally so you can control how much time is spent in it. I also recommend you monitor the GC statistics during the execution of the application so that you will know when to increase the frequence of the GC execution.
The garbage collector should preferably be invoked periodically, so that it can collect garbage before too much is accumulated. It's recommended to run it incrementally so you can control how much time is spent in it. I also recommend you monitor the GC statistics during the execution of the application so that you will know when to increase the frequence of the GC execution.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Quote: Original post by WitchLord
You don't have to release the module, you can just add new script sections to it and then call build on it. This will automatically release the previous resources held in the GC. The same for the context, as it is reused it will release the previous resources.
Now I'm confused.
When I add a new script section, can I give it the same name as the previous? How will angelscript know, that I don't plan to use the old section? Do I have to call the GC right after adding the new section to get rid of the old?
Thanks for the help!
When you call Build on the asIScriptModule, it will compile the script in the script sections, then it will free the script sections. So when you add new script sections these will only be used when you call Build again, after which they will be freed.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
When the Build function is called, or if you do an explicit DiscardModule.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement