How to free memory ater use of "new" to allocate it.
    Alain De Vos 
    devosalain at ymail.com
       
    Mon Jul 17 03:41:42 UTC 2023
    
    
  
The following program prints two different addresses.
Meaning the new allocates memory until the program dies.
So the means memory leak by default ?
```
import std.stdio:writefln;
import object: destroy;
import core.memory: GC;
void dofun(){
     auto a=new int[1000];
     writefln("%12x",&a);
     destroy(a);
     GC.free(a.ptr);
}
int main(){
     dofun();
     auto b=new int[1000];
     writefln("%12x",&b);
     return 0;
}
```
    
    
More information about the Digitalmars-d-learn
mailing list