[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: GC and threads
- From: "Bilyk, Alex" <ABilyk@...>
- Date: Tue, 27 Apr 2004 15:04:53 -0700
Who holds references to your Lua threads on Lua side? If you don't explicitely create some hard reference to your threads on Lua side they will be GCed without you knowing it. You might be crashing because of this.
What is the life-span of C++ objects vs Lua threads? Do they have the same life span? Do you intend them to have the same life-span? Usually, when you aggregate two objects that depend on each other with their life, you would have to make sure they die together or in some otherwise controlled fashion.
I make Lua do the cleanup in my code because usually there is no controll over the referencing of Lua objects. So, whenever Lua side is GCed my C++ side gets deallocated too (via GC event of a C++ userdata associated with the Lua object), not the other way around.
Alex
>-----Original Message-----
>From: Hassink, Brian [mailto:BHassink@Ciena.com]
>Sent: Tuesday, April 27, 2004 1:31 PM
>To: 'lua@bazar2.conectiva.com.br'
>Subject: GC and threads
>
>
>Hi,
>
>If I have a thread that is currently blocked on a lua_yield()
>call, is there a way to invalidate the thread (via the C API)
>such that it will be garbage collected?
>
>I'm creating and destroying C++ objects that have Lua threads
>associated with them. When a C++ object is destroyed, it's
>associated Lua thread will never resume, and I suspect will
>never be garbage collected as a result. I'd like to avoid
>passing in a special parameter via the lua_resume() call to
>tell the thread to exit it's main loop.
>
>I'm experiencing a crash in Lua after roughly 50 threads are
>orphaned as described above, and I try to create more.
>
>Cheers,
>Brian
>
>
>