Does a Coroutine automatically close or do I need to use coroutine.close() after?

I use A LOT of coroutines in my project and I’ve been noticing that the game slowly gets more and more laggy seemingly due to a memory leak. I’ve looked a lot and I cant find anything that could be causing it. Just a simple question, do I need to use coroutine.close() after every single coroutine or will it be dead after it finishes?

I always use:

coroutine.resume(coroutine.create(function()
	--Code
end))
4 Likes

try it out and see if it fixes the lag

3 Likes

Please check DevForum before asking questions, there are many posts about this exact question.

2 Likes

I did check but I guess I somehow missed it, thanks.

2 Likes

No problem! Sorry for being a bit harsh. What was the solution? I have never heard of Coroutine until this.

coroutine terminates itself automatically

According to the post @earthyviking92 linked, it does not and it collects overtime and cause memory issues when you have a lot of them so I’ll just have to kill them every time I use one. I’ll do some testing before I draw any conclusions though. :+1:

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.