'LinKin Posted March 1, 2014 Share Posted March 1, 2014 Hello, I've a table (like a matrice of 2 columns) I store the online players' name and element (table.insert(myTable,{playerName, theElement})) But then, how can I clear it? if I use a loop and do table.remove(myTable, i) it doesn't work. I mean something crashes there and the table is not really cleared but all messed up. I'm currently doing myTable = { } But is that a good way to do it? I want to save memory space. So how can I clear the table properly? Link to comment
Bonsai Posted March 1, 2014 Share Posted March 1, 2014 As far as I know you have to nil things to make Lua clear it. Link to comment
csiguusz Posted March 1, 2014 Share Posted March 1, 2014 myTable = {} is the same as myTable = nil. The garbage collector at the next cycle will clear the memory used by the table in both cases. The only difference is that if you used nil, and want to use the variable again as a table you have to declare it again like myTable = {}. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now