Sign in to follow this  
aayudh

question on lua Coroutines

Recommended Posts

aayudh    124
Hi, What happens if we never resume a lua coroutine ? How will it get freed runtime ? Is there a way to say, "I am not going to resume you anymore...just go and die", to the coroutine ?? -madan

Share this post


Link to post
Share on other sites
gekko    478
I'm not positive, but I believe it stays in memory and is never garbage collected. I ran into quite a few issues recently running out of memory when I had scripts controlling the behavior of hundreds of objects. I believe this was one of the main causes.

You can easily pass a parameter to resume which you could use to determine if you want to end the script or not. At least you can bring the coroutine to a "dead" status that way. I've been looking into it, and information on the inner workings of the language seems to be hard to find. Hopefully someone knows the details.

Share this post


Link to post
Share on other sites
aayudh    124
but parameters to coroutine.resume are stored onto the function stack and don't change. I dont know if it is mentioned, but you only need to pass parameters to resume once. The next time, you dont need to specify them !!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this