-
Posted by jodyblau on Mon, 07 Sep 2009 18:44:15
I'm used to programming in C# and C++, and this is my first attempt at learning LUA.
I'm trying to figure out how to manage memory usage in my addon.
If i store tables within tables, do I need to loop through them at some point and release the memory?
What about using CreateFrame()? How does one destroy the frame to release the memory?
Thanks,
Jody
-
Posted by jnwhiteh on Mon, 07 Sep 2009 19:11:12
I'm used to programming in C# and C++, and this is my first attempt at learning LUA.
I'm trying to figure out how to manage memory usage in my addon.
You don't, Lua is a managed language.
If i store tables within tables, do I need to loop through them at some point and release the memory?
A table is eligible for garbage collection when there are no more references to it in the system. All you need to do is ensure that if you want to allow a table to be garbage collected, nil out any references to it. For example:
tbl = {} for i=1,10000 do tbl[i] = {} end tbl = nil
Although we create a very large table, we
nil
out the single reference and the entire structure is eligible for garbage collection.What about using CreateFrame()? How does one destroy the frame to release the memory?
You cannot destroy them. They are never garbage collected.