Manually relesing memory

Vlad Stanimir vladbv2006 at gmail.com
Sat Dec 9 10:12:11 UTC 2023


I am new to the language and am curios about manual memory 
management options.

 From what i can tell dlang offers the option for both manul and 
automatic management of memory resources.

The language provides the ability to create your own allocator 
which is nice but i am a bit confused about the the situation 
with delete. The documentation states that it is deprecated and 
that __delete if you realy have to.

However GC.free apears to do the same thing (dealocate memory 
alocated by the GC) so the question is can memory alocated with 
new be dealocated with free or is it like like c/c++ where you 
are not allowed to mix the 2?

In addition is it posible to controll when the GC runs, i know of 
the existance of enable, disable and collect however it is not 
clear about the behaviour.

Does disable simply pause the GC automatic collection or does it 
behave like @nogc where you cant use heap memory at all and can 
collect be called when disable is in force or do i need to call 
enable 1st.


More information about the Digitalmars-d-learn mailing list