lua-users home
lua-l archive

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


> De : lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] De la part de Fredrik Widlund
> Envoyé : vendredi 1 octobre 2010 12:00
> À : lua-l@lists.lua.org
> Objet : Lua lanes (possibly) leaking memory

> Hi,

> We're having a memory leakage problem with Lua and Lanes. 


After a bit of examining your sample, I've changed it as follows:

require "lanes"

function sensor(x)
	return x
end

local x = 0
local linda = lanes.linda()
lanes.timer(linda, "timer", 1, 0.01)
local lane = lanes.gen("*", sensor)
while true do
	local time, message = linda:receive("timer")
	local lane_h = lane(time)
	-- local result = lane_h[1]
	x = x + 1
end


Note that I've commented out the line 

local result = lane_h[1]

Meaning that I don't read the result in the lane object. Running the script indeed shows a memory usage growth. If I uncomment the line, memory usage becomes stable. I think that since you never join the lanes, either with lane_h:join(), nor by reading the values, you just create a host of "free running lanes" that run outside control of the Lua main thread.