|
On 18.11.2014 06:47, arioch82 wrote:
>From what i understand if the coroutine is freed then all local variables
inside that function should be garbage collected, at that point the userdata
shouldn't have any references anymore and should be collected too but for
some reason this is not happening.
Every running function (and all the functions that called it) are referenced from the Lua stack and would not be collected even if there are no other references to them. This is a good thing that prevents crashes ;)
Corotines are actually functions called in separate Lua (sub-)states with a corotine library doing some scheduling. Therefore even yielded corotine is "running function" for the purposes in the first paragraph.
Your solution is to replace "while true do" with some more meaningful condition and call the corotine one more time when destroying to let it exit.
Best,
Anton