Getting completely (I mean ENTIRELY) rid off GC

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 11 08:39:16 PDT 2014


On Thu, 11 Sep 2014 15:23:53 +0000
Andrey Lifanov via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> is that in case of manual memory management I know completely 
> when and what will be freed or allocated (with the help of smart 
> pointers/reference counting, of course).
but you don't. you can only estimate, that's all. what if you passing
refcounted object to another function which stores it somewhere? oops.

and in D you are free to use structs, `scoped!`, and malloc()/free()
(see std.typecons for "scoped" template source to see how it's done).

you can write your own array implementations too. slices are hard to do
without proper GC though, and closures requres GC, AFAIK.

> So maybe instead of getting rid of GC I will consider the 
> implementation of optimized moving GC.
copying GC requires support from the compiler side, and it is not that
easy at all (imagine malloc()ed blocks which holds references to
GC-alloced objects, for example). current D GC is conservative, so you
can just register malloc()ed block as root, but for copying GC you'll
need either to inform GC about exact block structure, or provide your
own scan/copy/fix callbacks.

and if copying GC will not do 'stop-the-world', some threads can hold
pointers in registers... and inserting read/write barriers will hurt
performance...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140911/acaa0835/attachment.sig>


More information about the Digitalmars-d mailing list