View Single Post
07-11-12, 07:45 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
The way Lua stores tables, it reserves 2 arrays per table, one holds sequential indices and the other holds associative ones. When needed, Lua expands these arrays in powers of 2, but they never shrink back down when a value in the table is set to nil. This means when you build a table, then iterate through it to set everything to nil, the allocated space for the indices are still there. Usually, when you release a table, it stays in memory until the garbage collector comes to deallocate the memory used. You can force the garbage collector by calling collectgarbage("collect"). This will halt execution for the garbage collector to run, so it's not wise to use often or in moments of high CPU usage. Alternatively, Blizzard added the wipe() function to the API. I don't know how far it goes as far as cleaning up used memory. That might be something to test.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-11-12 at 07:48 PM.
  Reply With Quote