How to use destroy and free.
    Ali Çehreli 
    acehreli at yahoo.com
       
    Tue Apr 26 01:03:35 UTC 2022
    
    
  
On 4/25/22 16:02, frame wrote:
 > On Monday, 25 April 2022 at 02:07:50 UTC, Ali Çehreli wrote:
 >> >      import core.memory: GC;
 >>      GC.free(GC.addrOf(cast(void *)(i.ptr)));
 >> That is wrong because you did not allocate that address yourself.
 >
 > Hmm? The GC did allocate here(?)
Yes. I still don't understand the need to free GC memory explicitly. I 
can understand GC.collect() but not the memory of a specific array.
 >> On 4/24/22 17:26, Salih Dincer wrote:
 >>
 >> >    MEM.free(i.ptr);
 >> >    // You don't need to addrOf(cast(void*)i)
 >
 > Wrong.
You are right. I missed the fact that addrOf is a GC function.
Ali
    
    
More information about the Digitalmars-d-learn
mailing list