www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D garbage collector and real-time systems

reply "Tom" <tom.k.cook gmail.com> writes:
What's the state of deterministic GC in D, or alternatively being
able to disable the GC?

I've been looking into languages to implement a real-time testing
system and had thought of D, but AFAICT the GC makes it
unsuitable.  The CGCD effort looks to be moving in the right
direction, but it would still be stop-the-world, just not for as
long as it used to.

Something like Lua's iterative GC would be better, as I think it
would give deterministic real-time latency alongside the GC (by
making the GC interruptible).  Are there any plans in this
direction?

Or is there now the possibility of disabling the GC altogether,
or replacing it with a refcounting 'GC' etc?
Jan 27 2015
next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Wed, 28 Jan 2015 06:58:41 +0000, Tom wrote:

 Or is there now the possibility of disabling the GC altogether, or
 replacing it with a refcounting 'GC' etc?
you still can do manual memory management with `malloc()` and friends.=20 but you must be very cautious with dynamic arrays and slices. may be your=20 best bet is to not use built-in dynamic arrays at all and write a=20 replacement class with manual memory management. ah, and the same for AAs. it's possible, if somewhat cumbersome. and you can use 'dmd -vgc' to=20 check for hidden allocations. so it may be not as simple as adding some=20 compiler switch, but still not that hard too.=
Jan 27 2015
parent "Nicholas Wilson" <iamthewilsonator hotmail.com> writes:
On Wednesday, 28 January 2015 at 07:43:35 UTC, ketmar wrote:
 On Wed, 28 Jan 2015 06:58:41 +0000, Tom wrote:

 Or is there now the possibility of disabling the GC 
 altogether, or
 replacing it with a refcounting 'GC' etc?
you still can do manual memory management with `malloc()` and friends. but you must be very cautious with dynamic arrays and slices. may be your best bet is to not use built-in dynamic arrays at all and write a replacement class with manual memory management. ah, and the same for AAs.
There is also bitbucket.org/infognition/dstuff for some other gc related hacks that may be of use.
Jan 28 2015
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
http://dlang.org/phobos/core_memory.html#.GC.disable ?
Some people including myself write D with only minimal runtime 
(bare metal profile). Is it what you're looking for?
Jan 27 2015
prev sibling parent reply "Mike" <none none.com> writes:
On Wednesday, 28 January 2015 at 06:58:42 UTC, Tom wrote:
 Or is there now the possibility of disabling the GC altogether,
 or replacing it with a refcounting 'GC' etc?
You can disable the GC: http://dlang.org/phobos/core_memory.html#.GC.disable There is a RefCounted struct in the standard library: http://dlang.org/phobos/std_typecons.html#.RefCounted But, last I heard there were some problems with it: http://forum.dlang.org/post/cakobtxrmvrpqhswmfsy forum.dlang.org I suggest reading this article: http://wiki.dlang.org/Memory_Management. It provides more information and working examples illustrating some techniques for avoiding the garbage collector. Note that D has 3 built-in types: exceptions, dynamic arrays, and associative arrays, that may be difficult to use without the GC: http://dlang.org/builtin.html. Mike
Jan 28 2015
parent Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 01/28/2015 09:12 AM, Mike wrote:
 Note that D has 3 built-in types: exceptions, dynamic arrays, and
 associative arrays, that may be difficult to use without the GC:
 http://dlang.org/builtin.html.
4 actually, if you count delegate closures. http://dlang.org/function.html#closures
Jan 30 2015