Rekindled Phoenix Posted July 4, 2011 Share Posted July 4, 2011 I wrote a small bit of code to cycle though a collection of entities and draw lines between their positions. The objects were not creating any new meshes, only drawing and looping through collections. I had the fortunate mistake of leaving my computer on while eating lunch, and encountered an out of memory exception within the Sandbox. So I ask... 1. When is the optimal place to use local? What object datatypes are best, if any? 2. Is it possible calling functions within another function delays the garbage collector? 3. using collection = classnametable["info_pathing_node"], can I call this once and reuse it? Or do I have to create it every loop in case a new object was added? 4. Will calling AddHook() with a function cause a small memory leak over time? Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 4, 2011 Share Posted July 4, 2011 do you do garbage collection any where in your script? see this post that had the same problem with the viperscript and the modified oildrum scripts: http://www.leadwerks.com/werkspace/topic/2178-mem-usage-grows-continuously/page__view__findpost__p__20049 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted July 4, 2011 Author Share Posted July 4, 2011 I didn't think that I would have to manually call the garbage collector for a script engine... but whatever works! collectgarbage(collect) should work if I'm specifying the exact objects in quesiton. Quote Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted July 4, 2011 Author Share Posted July 4, 2011 Can anyone answer the other questions? Quote Link to comment Share on other sites More sharing options...
TylerH Posted July 4, 2011 Share Posted July 4, 2011 I wrote a small bit of code to cycle though a collection of entities and draw lines between their positions. The objects were not creating any new meshes, only drawing and looping through collections. I had the fortunate mistake of leaving my computer on while eating lunch, and encountered an out of memory exception within the Sandbox. So I ask... 1. When is the optimal place to use local? What object datatypes are best, if any? 2. Is it possible calling functions within another function delays the garbage collector? 3. using collection = classnametable["info_pathing_node"], can I call this once and reuse it? Or do I have to create it every loop in case a new object was added? 4. Will calling AddHook() with a function cause a small memory leak over time? 1. Inside of a function is the best place, but mainly in an object script at the very top doing all your initial declarations, you don't have to assign variables at that point either, just best to have them declared locally before you do anything else. 2. Nope, its stack based. 3.You can reused something like that though it depends on if you deleted collection. As long as it isnt nil it will overwrite each loop without you redeclaring. 4. Can't answer, don't know how it was coded. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted July 5, 2011 Author Share Posted July 5, 2011 Thank you Tyler, those questions have been numbing my mind for the last couple of days. 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.