I keep reading that Nim's memory management is optional, but documenttion seems to be thin on this, the only resources I have found relate mostly to FFI to C, and https://nim-lang.org/docs/gc.html
Is it possible to take control of Nim's memory management short of writing a new GC? Any good resources?
Nim has 5 default GC methods and the upcoming automated reference counting.
Swift uses Automatic Reference Counting (ARC) to track and manage your app's memory usage. In most cases, this means that memory management “just works” in Swift, and you don't need to think about memory management yourself.
As briefly mentioned above, there are two types of pointers in Nim: ptr T for untraced references, aka pointers.
The only thing you can do to take control over the GC are listed on the docs page you listed. You can control when, and for how long the GC will run. The second option is to completely disable the GC, which allows you to manually manage memory in a more C like fashion with explicit allocations and frees. The third option, which is still very experimental, is called "newruntime" and is outlined here: https://nim-lang.org/araq/ownedrefs.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With