How to free memory ater use of "new" to allocate it.

Alain De Vos devosalain at ymail.com
Sun Jul 16 18:18:08 UTC 2023


I don't use malloc

```
import std.stdio: writeln;
    2   │
    3   │ class C{
    4   │     int[] i=null;
    5   │     this(){
    6   │         writeln("Allocate heap");
    7   │         i=new int[10000];
    8   │         writeln(typeid(typeof(i)));
    9   │         writeln(typeid(typeof(i.ptr)));
   10   │         i[9000]=5;
   11   │     }
   12   │     ~this(){
   13   │         writeln("Free heap");
   14   │         import object: destroy;
   15   │         import core.memory: GC;
   16   │         i=null; // But How to force GC free ? 
-------------?
   17   │     };
   18   │ }
```


More information about the Digitalmars-d-learn mailing list