Lets say in theory I'm spawning/using tens or hundreds of thousands of channels, what's the best way to ensure the garbage collector is doing it's thing?
For named channels, just :clear and dereference them, done.
But how about for unnamed channels? Does the thread that spawned the channel have to :clear it? Will they automatically destruct if there is nothing in their queue, since no references exist for them? Or do they stick around as long as something might want to use them? Would it be best to stick with named channels since they can be explicitly destroyed?
Garbage Collecting Unnamed Channels
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- parallax7d
- Citizen
- Posts: 82
- Joined: Wed Jul 02, 2014 11:44 pm
Re: Garbage Collecting Unnamed Channels
Channels get garbage collected the same way other objects do. As soon as you let go of the last reference to the channel, GC is free to collect it and destroy all data in it.
- slime
- Solid Snayke
- Posts: 3133
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Garbage Collecting Unnamed Channels
Unnamed channels stick around until there are no Lua-side references, even if they still have stuff in their Queue. Named channels stick around until there are no Lua-side references and they have nothing in their queue. That said, creating tens or hundreds of thousands of Channels doesn't sound like a great idea - I recommend reusing Channels as much as possible.parallax7d wrote:But how about for unnamed channels? Will they automatically destruct if there is nothing in their queue, since no references exist for them?
Who is online
Users browsing this forum: Bing [Bot] and 236 guests