How to allocate/free memory under @nogc
Steven Schveighoffer
schveiguy at gmail.com
Thu May 21 15:09:57 UTC 2020
On 5/20/20 10:50 PM, data pulverizer wrote:
> how do you allocate/free memory without using the garbage collector?
Use C malloc and free.
> Does allocating and freeing memory using `GC.malloc` and `GC.free` avoid
> D's garbage collector?
No, an allocation can trigger a collection. D does not have a scheduled
GC, it basically runs the GC when it can't allocate any more memory from
it's pools before it tries to get more from the OS.
I *think* that @nogc is supposed to mean "Be able to run this without a
GC implemented", not that no collections will run.
-Steve
More information about the Digitalmars-d-learn
mailing list