Re: When are coroutines collected?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: When are coroutines collected?
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2008年2月27日 12:30:33 -0300
> Consider the following:
>
> run = {}
> for i=1, 100000 do table.insert(run, coroutine.create(function() end)) end
> print(coroutine.status(run[1]))
> for k,v in ipairs(run) do coroutine.resume(v) end
> print(coroutine.status(run[1]))
> run = {}
> collectgarbage("collect")
>
> At the end all the coroutines are "dead" yet they are still taking up
> memory. It looks like they have not been collected. [...]
I failed to see this behavior. Adding print(collectgarbage("count")) at
the beginning and at the end of that script, my machine (running Lua
5.1.1) gives the following output:
19.3125
suspended
dead
18.1572265625
-- Roberto