lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello, List!

Please consider the following code:

------- test.lua ------

local function printState()
	collectgarbage 'collect'
	print(collectgarbage 'count')
end

printState()
do
	local t = {}
	for i = 1, 10000 do
		local co = coroutine.create(function () end)
		debug.sethook(co, function () end, 'l')
		table.insert(t, co)
	end
end
printState()

--------------------

Output:

$ lua test.lua
27.6533203125
1058.3408203125

$ luajit-2.0.0-beta9 test.lua
23.71875
24.5673828125


After a little investigation into what may occupy memory,  I found that debug.sethook() leaves some internal data in the registry despite the corresponding coroutines have been collected. LuaJIT manages to free them as it probably should.

// Seny