lua-users home
lua-l archive

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


Hi Eric,
 
Thanks for the reply, I am currently solving it by iterating the stack and removing the co-routine when i have decided it is dead, this work but it's a little 'ick', my main issues were that I didint know (and the documentation did not specify) that the co-routines do not die upon completion.
 
it seems the optimal situation would be to increase the reference count of the new thread when i create it, and immediately pop it off the stack (since when i need to get it later the position is not predictable and i need to search) and then later be able to decrement the ref count by simply having the lua_State* that represents the co-routine.
 
any thoughts on that?
 
-Raymond

 
On 4/12/06, Eric Scouten <scouten@adobe.com> wrote:
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