Hello! if i have a coroutine task and i call a joi...
# coroutines
e
Hello! if i have a coroutine task and i call a join on it
task.join()
and this join never returns than i do have a memory leak, don’t i?
c
if this coroutine could take too long to reply, you can use
withTimeout
to define a limit
n
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.
🙏 1
c
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