lua-users home
lua-l archive

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

Yes, I'm testing this now and it seems much more stable. I've also tried to let lanes "loose" using lanes.gen(function() ... end)(), but this does not seem to work and memory increases. 

I don't want to do a blocking wait, but I guess I can check the lanes for status and collect the results when they are finished without blocking.

Great help, guys! Thanks a lot, this should help me. 

However letting lanes "loose" still seems to be a problem, i.e.
local linda = lanes.linda()
lanes.timer(linda, "timer", 0, 0.01)
while true do
   local time, message = linda:receive("timer")
   lanes.gen(function () return 0 end)(lanes, lanes, lanes, lanes, x)

Kind regards,
Fredrik Widlund

-----Original Message-----
From: [] On Behalf Of Benoit Germain
Sent: den 1 oktober 2010 13:31
To: Lua mailing list
Subject: RE: Lua lanes (possibly) leaking memory

> 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.