lua-users home
lua-l archive

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


Anything that's on an active lua_State cannnot be garbage collected. You'll need to manage the lifetime of this coroutine at least a little bit, by having a reference to it somewhere that goes away upon completion.

-Eric



On 12 Apr 2006, at 10:25, Raymond Jacobs wrote:

I have noticed a problem when I create a large amount of co-routines from C code.
 
it seems that when i call:  cr=lua_newthread(state);
 
it is pushed onto the stack of 'state' per the documentation.
 
however after I have loaded code and run the co-routine using lua_resume, it's status is still '0', and the thread never gets garbage collected, eventually resulting in a stack overflow.
 
it seems that by manually popping the thread off of the 'state' stack stops this problem, but I was under the impression that after running the co-routine it should be 'dead' and thus garbage collected.
 
do I /really/ need to go back and pop these threads off of the stack after they are done?
 
and if the status always returns 0 how can I know when they are done?
 
Thank you for your time,
 
Raymond Jacobs
Ethereal Darkness Interactive