| Message |
Larkin said:
function leaker()
local something = {}
for i=1,50000 do
table.insert(something, "blahblahblah")
end
return something
end
function testleak()
local a = leaker()
end
OK, if you run "testleak ()" there is no reason, yet, for it to collect the garbage. Inside leaker it is validly using a lot of memory. After you run testleak the variable "a" goes out of scope, but the script ends. You would need to do something else afterwards to trigger off garbage collection, and I'm not sure what that would be.
Some tests seem to indicate that just running some simple scripts don't do it (of course, doing collectgarbage does).
Judging by what little I have read, there would be a trigger point. In your case you may have used 1 Mb of memory, the trigger point might be when another 1 Mb is used.
I seem to recall, but can't find it right now, that in my mapper I just collected garbage after drawing the map. All those temporary tables got cleaned up then. I don't see any harm in that, as you know you have used temporary things, you know you are finished with them, and a slight extra delay after drawing the map won't annoy people too much. However running out of memory later on, will.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|