lua-users home
lua-l archive

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


On Mar 25, 2011, at Mar 25 10:05 AM, Roberto Ierusalimschy wrote:

>> I allocate a userdata and then call lua_setfenv to set an environment
>> table for it. Then I allocate a 2nd userdata and store it in the
>> environment table. Eventually Lua collects the 1st userdata.
>> 
>> I assume that the 2nd userdata will not be collected until the
>> reference in the environment table goes away. Is that correct?
> 
> Mostly, but there is one detail: when the state is closed, if both
> userdata are still alive, the 2nd userdata will be collected before the
> 1st one, despite the reference.
> 
> -- Roberto
> 

Is the 2nd userdata collected first because it was allocated after the 1st one? Are userdata collected in reverse order of their allocation?