Re: How about use Gc as a big memory pool?

2016-04-08 Thread Dsby via Digitalmars-d-learn

On Friday, 8 April 2016 at 05:31:10 UTC, Olivier Pisano wrote:

On Friday, 8 April 2016 at 03:27:04 UTC, Dsby wrote:

when the soft start, call GC.disable().
use "new " create a class , struct or a array. and use 
destory(T/void *) to call the ~this(), then GC.free to free 
the memory, and use RAII in class or Struct.
And user the Timer, or in some where to call : GC.enable(), 
GC.collect(), GC.disable();


In this way , i can know and control when is GC runing.

Is This way   feasible? will It  have a problem?


It should work, but you cannot predict how much time collect() 
will take, since it depends on the system state (how much work 
it has to do). So instead of calling it at fixed intervals, 
you'd better call it when your application is idle.


Why don't you try to use 
https://dlang.org/phobos/std_experimental_allocator.html ?


It work. before 2.071, in the ~this call GC.free will Erro. now 
it is fine.

I know and used experimental_allocator.

but new is better than theAllocator.make!(), in read, and write.


Re: How about use Gc as a big memory pool?

2016-04-07 Thread Olivier Pisano via Digitalmars-d-learn

On Friday, 8 April 2016 at 03:27:04 UTC, Dsby wrote:

when the soft start, call GC.disable().
use "new " create a class , struct or a array. and use 
destory(T/void *) to call the ~this(), then GC.free to free the 
memory, and use RAII in class or Struct.
And user the Timer, or in some where to call : GC.enable(), 
GC.collect(), GC.disable();


In this way , i can know and control when is GC runing.

Is This way   feasible? will It  have a problem?


It should work, but you cannot predict how much time collect() 
will take, since it depends on the system state (how much work it 
has to do). So instead of calling it at fixed intervals, you'd 
better call it when your application is idle.


Why don't you try to use 
https://dlang.org/phobos/std_experimental_allocator.html ?


How about use Gc as a big memory pool?

2016-04-07 Thread Dsby via Digitalmars-d-learn

when the soft start, call GC.disable().
use "new " create a class , struct or a array. and use 
destory(T/void *) to call the ~this(), then GC.free to free the 
memory, and use RAII in class or Struct.
And user the Timer, or in some where to call : GC.enable(), 
GC.collect(), GC.disable();


In this way , i can know and control when is GC runing.

Is This way   feasible? will It  have a problem?