Hello! if i have a coroutine task and i call a join on it
and this join never returns than i do have a memory leak, don’t i?
07/06/2021, 4:58 PM
if this coroutine could take too long to reply, you can use
to define a limit
07/06/2021, 8:11 PM
You may or may not have a memory leak. To the garbage collector, coroutines are just objects, and they get cleaned up too if nothing is referring to them. The coroutine waiting for join will hang on to references it needs for resume, but if the coroutine isn't referenced (specifically the continuation) then it could all get GC'd. So it really depends. I'd be more concerned from a design perspective about a join that never returns, sounds suspicious.
07/07/2021, 11:16 AM
Join in coroutines doesn't do memory management (unlike pthread_join, if that's why you're asking). Launching & joining or launching and not joining doesn't make a difference, because the GC handles memory in all cases.
So not having a join is not a memory leak in itself, but as the others have said it depends what else you're doing. If you want you can send a more detailed example of what you're doing so we can help with the details