Re: strange work of GC

2015-02-08 Thread FG via Digitalmars-d-learn
On 2015-02-08 at 06:36, Mike Parker wrote: On 2/8/2015 11:32 AM, FG wrote: On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. Thi

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 11:32 AM, FG wrote: On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. This gives you the deterministic destruction th

Re: strange work of GC

2015-02-07 Thread FG via Digitalmars-d-learn
On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. This gives you the deterministic destruction that you want (the same as calli

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 4:32 AM, Andrey Derzhavin wrote: Why do you want to use destroy? The destroy method always calls a dtor of the objects, where I can destroy some object's variables in that order that I need, I think. And this is very good for me, because I have a full control of the object's destroyi

Re: strange work of GC

2015-02-07 Thread Andrey Derzhavin via Digitalmars-d-learn
Why do you want to use destroy? The destroy method always calls a dtor of the objects, where I can destroy some object's variables in that order that I need, I think. And this is very good for me, because I have a full control of the object's destroying stage. But if I use the GC, I have no gar

Re: strange work of GC

2015-02-07 Thread FG via Digitalmars-d-learn
On 2015-02-07 at 12:02, Andrey Derzhavin wrote: If a "destroy" method is used together with GC inside of my app,it makes my app unstable. In this case I need to choose how to destroy my objects: 1) always manually by method "destroy", but without GC; 2) or always automatically by GC, but withou

Re: strange work of GC

2015-02-07 Thread Andrey Derzhavin via Digitalmars-d-learn
If a "destroy" method is used together with GC inside of my app,it makes my app unstable. In this case I need to choose how to destroy my objects: 1) always manually by method "destroy", but without GC; 2) or always automatically by GC, but without using the "destroy" method. In the first case

Re: strange work of GC

2015-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 February 2015 at 20:38:07 UTC, Andrey Derzhavin wrote: As I think, the garbage collector should start destoying of the C1 and C2 objects of arr array during the "while" cycle prosess, but this does not happen. Dtors are not called. The D GC only runs on demand - typically, when y

Re: strange work of GC

2015-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 February 2015 at 21:07:14 UTC, anonymous wrote: This is you GC allocating in a destructor (the writeln calls). The GC can't handle that. Note that it isn't writeln itself, it is the ~ used in building the string. If you change that to a comma, it'll work better (writeln can take

Re: strange work of GC

2015-02-06 Thread anonymous via Digitalmars-d-learn
On Friday, 6 February 2015 at 20:38:07 UTC, Andrey Derzhavin wrote: As I think, the garbage collector should start destoying of the C1 and C2 objects of arr array during the "while" cycle prosess, but this does not happen. Dtors are not called. Garbage is only collected when you allocate memo

strange work of GC

2015-02-06 Thread Andrey Derzhavin via Digitalmars-d-learn
class C1 { int a1, b1, c1, d1, e1; string sdb1; this(string s) { sdb1 = s; a1=90; b1=19; d1=22; e1=23; } ~this() { if (sdb1 == "lll")