How about use Gc as a big memory pool?

Olivier Pisano via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 7 22:31:10 PDT 2016


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 ?


More information about the Digitalmars-d-learn mailing list