It looks like you're new here. If you want to get involved, click one of these buttons!
function TestInit() TestList = {} end function TestCreate(name, xPos, yPos, Direction, parentGroup) local TTest = { name = name, xPos = xPos, yPos = yPos, Direction = Direction, anotherList = {}, parentGroup = nil } TestList[name] = TTest TestList[name].name = name TestList[name].xPos = xPos TestList[name].yPos = yPos TestList[name].Direction = Direction TestList[name].parentGroup = parentGroup return TestList[name] end function TestDone() for key,value in pairs(TestList) do value.anotherList = nil TestList[key] = nil end TestList = nil end -- test print ("memory used:"..collectgarbage("count")) TestInit() TestCreate("ciao", 10,10,33,nil) TestCreate("ciao3", 10,10,33,nil) TestCreate("ci22", 220, 410, 56, nil) TestCreate("ci232", 220, 410, 56, nil) TestDone() print ("memory used:"..collectgarbage("count")) |
Comments
In fact, there is no memory leak. Just call collectgarbage() before printing collectgarbage("count")
Well at least my code is not badly written! ..
thanks atilim... friendly as always!.
www.tntengine.com