lua-users home
lua-l archive

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

> De : [] De la part de Fredrik Widlund
> Envoyé : vendredi 1 octobre 2010 12:00
> À :
> 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

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

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.