-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Create or document way to clear all global memory #21403
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
Comments
After writing this I discovered |
Did some testing and exposing |
related #18262 |
Just for reference if someone wants to give a go at implementing this. I believe that this procedure is what needs to be ported to ARC/ORC and then create a Lines 434 to 458 in 39d0a93
|
Makes sense but this new |
Hmm, that's a bit unfortunate. But still better than just leaving all the memory dangling. Does |
|
is this also addressed by e217bb2 ? |
Summary
This came about when working with dynamic libraries. If you write a dynamic library in Nim and then load it into a separate program there is no (documented) way to free all the memory if the loader program unloads the dynamic library. This means that if a system loads and unloads a dynamic library it will keep increasing in memory.
Description
What I propose is to create a procedure
NimQuit
opposite ofNimMain
which will destroy all memory. Calling any other code using GC after that will be undefined behaviour. This would then be called automatically in.fini
by attaching__attribute((destructor))__
or hooking inDllMain
, similar to howNimMain
is called today. And analogous to how--noMain
disables this behaviour--noQuit
should prevent it from being called andNimQuit
must be called exlicitly.Alternatives
No response
Examples
As a simple example/testing ground I wrote this:
loader.nim
:library.nim
:Compiled with:
and
Backwards Compatibility
No response
Links
No response
The text was updated successfully, but these errors were encountered: