SourceSimian
SourceSimian

Reputation: 740

Nim and memory management

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?

Upvotes: 7

Views: 1109

Answers (1)

PMunch
PMunch

Reputation: 1734

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

Upvotes: 6

Related Questions