How to allocate/free memory under @nogc

Konstantin kostya.hm2 at gmail.com
Thu May 21 17:19:10 UTC 2020


On Thursday, 21 May 2020 at 15:09:57 UTC, Steven Schveighoffer 
wrote:
> 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

Hi all! I will try to ask again(previous two posts still have no 
answers) : are there any site/page/docs somewhere to track actual 
info about @nogc support in language itself and in phobos 
library? Or, at least plans to extend such support?



More information about the Digitalmars-d-learn mailing list