Middleclass apparent memory leak ?
Posted: Sun Dec 26, 2010 1:51 pm
Hi
Newbie here, I have been experimenting a bit with Lua and the Middleclass library, an apparent memory leak with Middleclass has got me totally stumped. Is this really a leak or am I misunderstanding something.
I cut my code down to just the following lines
If I run this code repeatedly from a Lua console with dofile("myTest.lua") I get the following increasing memory usage.
Memory used after Garbage Collect = 43.8 kbytes
Memory used after Garbage Collect = 46.0 kbytes
Memory used after Garbage Collect = 48.2 kbytes
Memory used after Garbage Collect = 50.6 kbytes
If I add the line oPlayer = nil, that makes no difference either
The other things I tried made no sense to me.
Test 1
instead of the require("middleclass") line, I pasted in the middleclas lua code so everything was in the one file, to my surprise that fixes the memory leak ?
Test 2
Back with the original code with the single require "middleclass" line, if I run that under Scite, it shows no memory leak either ?
No idea whats going on here, can anyone explain this and help out a confused Newb please ?
Regards Geoff
Newbie here, I have been experimenting a bit with Lua and the Middleclass library, an apparent memory leak with Middleclass has got me totally stumped. Is this really a leak or am I misunderstanding something.
I cut my code down to just the following lines
Code: Select all
require "middleclass"
local oPlayer = class("A Player") -- This single line is enough to show a leak
collectgarbage("collect")
local endMem = string.format("\nMemory used after Garbage Collect = %.1f kbytes", collectgarbage("count"))
print (endMem)
Memory used after Garbage Collect = 43.8 kbytes
Memory used after Garbage Collect = 46.0 kbytes
Memory used after Garbage Collect = 48.2 kbytes
Memory used after Garbage Collect = 50.6 kbytes
If I add the line oPlayer = nil, that makes no difference either
The other things I tried made no sense to me.
Test 1
instead of the require("middleclass") line, I pasted in the middleclas lua code so everything was in the one file, to my surprise that fixes the memory leak ?
Test 2
Back with the original code with the single require "middleclass" line, if I run that under Scite, it shows no memory leak either ?
No idea whats going on here, can anyone explain this and help out a confused Newb please ?
Regards Geoff