digitalmars.D.learn - How about use Gc as a big memory pool?
- Dsby (8/8) Apr 07 2016 when the soft start, call GC.disable().
- Olivier Pisano (7/15) Apr 07 2016 It should work, but you cannot predict how much time collect()
- Dsby (5/22) Apr 08 2016 It work. before 2.071, in the ~this call GC.free will Erro. now
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?
Apr 07 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 ?
Apr 07 2016
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: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.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 ?
Apr 08 2016