Re: Why is it a memory ERRO.

2016-01-30 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 30 January 2016 at 05:50:33 UTC, Dsby wrote: Ok.Thank you. and i want to know how to know when the GC start runing? See also http://dlang.org/phobos/core_memory

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 January 2016 at 05:50:33 UTC, Dsby wrote: Ok.Thank you. and i want to know how to know when the GC start runing? For the current implementation, any time you allocate memory through the GC it will determine if a collection cycle is needed, but it will not run otherwise.

Re: Why is it a memory ERRO.

2016-01-29 Thread Dsby via Digitalmars-d-learn
Ok.Thank you. and i want to know how to know when the GC start runing?

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 13:22:07 UTC, Mike Parker wrote: Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need to call GC.free at all. The GC will collect both your object instance and the memory you allocated with new. Never, ever, manipu

Re: Why is it a memory ERRO.

2016-01-29 Thread Mike Parker via Digitalmars-d-learn
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote: the Code: ~this(){ GC.free(by.ptr); by = null; writeln("free"); } Your problem is probably that you are calling GC.free in the destructor. Don't do this. You don't need to

Re: Why is it a memory ERRO.

2016-01-29 Thread Dsby via Digitalmars-d-learn
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote: the Code: class MyClass { this(){ by = new ubyte[1]; ++i; } ~this(){ GC.free(by.ptr); by = null; writeln("free"); } v

Why is it a memory ERRO.

2016-01-29 Thread Dsby via Digitalmars-d-learn
the Code: class MyClass { this(){ by = new ubyte[1]; ++i; } ~this(){ GC.free(by.ptr); by = null; writeln("free"); } void show(){ writeln(i); }; privat