Jump to content

Memory optimization


Rekindled Phoenix
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

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

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.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

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.

 Share

×
×
  • Create New...