[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: garbage collection and setfenv
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 18 Mar 2008 21:55:28 -0300
> So let's say I say:
>
> function tryThis()
> myVar = { foo="baz" }
> end
>
> local env = {}
> setfenv(tryThis, env)
> tryThis()
>
> My question is: when does myVar get collected? With my current testing, it
> seems that myVar never gets collected. If so, how do I "convince" it to be
> collected?
'env' is the environment of 'tryThis' (which is global), so it cannot be
collected until tryThis is garbage or until you change its environment
again. You may try "tryThis = nil" or "setfenv(tryThis, {})".
-- Roberto