-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does this usage of asyncSpawn and ThreadSignalPtr leak memory? #542
Comments
Turns out you need to indeed call |
feel free to turn this into a documentation page outlining multithreaded / orc + chronos use |
Actually, pretty solid advice. |
For the purposes of decent examples with async-event-loop in other threads and cleaning up after them: |
Heyho, still trying to write my multithreading library and ensuring correctness with address sanitizer.
I've been running into memory leak issues of around 20KB with the way I have set up my code (meaning
asyncSpawn
on a Future at the start of a loop, and process the async-work that came from that at a later part in the loop whilewaitFor
-ing ThreadSignalPtr).I managed to condense it down into this minimal example, which I do not understand why that leaks:
There is nothing that should leak there.
All futures that exist from
processAsync
should be resolved once during thesleep
call.You can see that in the console as well since
Stuff
will get printed there.So what is leaking?
Command to compile:
nim r -f --debugger:native --cc:clang -d:useMalloc --passc:"-fsanitize=address -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" --passl:"-fsanitize=address -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" -d:release src/playground.nim
Address sanitizer stacktraces:
The text was updated successfully, but these errors were encountered: