On 7/16/23 11:41 PM, Alain De Vos wrote:
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;
}

```


No, what I am trying to explain is that `destroy(a)` is literally equivalent to `a = null`.

If you then `free(a)` do you think it does anything?

-Steve
  • Re: How to free ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
    • Re: How to ... Alain De Vos via Digitalmars-d-learn
      • Re: How... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: How... Steven Schveighoffer via Digitalmars-d-learn
        • Re:... Alain De Vos via Digitalmars-d-learn
          • ... Alain De Vos via Digitalmars-d-learn
            • ... Steven Schveighoffer via Digitalmars-d-learn
          • ... Steven Schveighoffer via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Alain De Vos via Digitalmars-d-learn
            • ... drug007 via Digitalmars-d-learn
              • ... Alain De Vos via Digitalmars-d-learn
                • ... drug007 via Digitalmars-d-learn
              • ... Alain De Vos via Digitalmars-d-learn
    • Re: How to ... Nick Treleaven via Digitalmars-d-learn
      • Re: How... Alain De Vos via Digitalmars-d-learn
        • Re:... Ernesto Castellotti via Digitalmars-d-learn

Reply via email to