Signals and Slots in D

Chad J "gamerChad\" at spamIsBad gmail.com
Fri Sep 29 06:54:51 PDT 2006


Thomas Kuehne wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Walter Bright schrieb am 2006-09-29:
> 
>>The problem in general with hiding pointers is that it'll break with a 
>>moving garbage collector. You could work around this by 'pinning' the 
>>objects, but pinning objects long term is a bad idea.
> 
> 
> How about an GC allocation area that isn't searched for valid pointers
> but is still collected?
> 
> Thomas
> 
> -----BEGIN PGP SIGNATURE-----
> 
> iD8DBQFFHPsFLK5blCcjpWoRAg5cAJ0Tg9vDT3A7N8XMOMBk5gkVBcU7twCgkVaM
> wl6LSgAw6xnyhduUo4tDKcI=
> =zWvW
> -----END PGP SIGNATURE-----

I wish we had such a gc area.

This could make the gc more efficient as well as solving weak references 
(at least weak refs on the heap).  You would have two allocation 
functions in the GC (ideally exposed for user code use, no more malloc 
please) - one that allocates on a heap that is scanned for pointers, and 
one that allocates on the unscanned heap.  The unscanned heap is still 
sweeped of course.  Then whenever the compiler sees something like int[] 
= new int[4096]; it will make sure that array data is allocated on the 
unscanned heap, since its type implies it will not contain pointers. 
Now the GC doesn't have to scan all 4096*4=16384 bytes of memory 
contained by that array, which in some cases will massively speed up the 
mark phase of a collection.

Currently there is some saving grace in the fact that when you use C 
libraries like SDL, a lot of your data will end up in the C heap, which 
accomplishes the same speed boost.  But that still has D reliant on the 
C heap, and said data isn't garbage collected unless you use wrappers or 
something :(  Ultimately this will bite us if we write libraries in D 
that use large data structures that contain no pointers (um graphics 
libs), so for example a D port of SDL would kinda suck right now unless 
it used malloc.

(end of sales speech for gc optimization/modification)



More information about the Digitalmars-d mailing list