On 23.05.2014 20:52, Etienne wrote:
On 2014-05-23 2:14 PM, Rainer Schuetze wrote:
BTW: How do you detect the sample pointers are alive? Or do you mean
just the roots?
You store a void** and the original value, dereference it to see if it's
the same value as the original. Loop through 20 of those if you have
500, and you update them during marking by taking 1 in 20.
Looking at the address where the reference is stored gives you a hint
about modifications, but does not say anything about whether the object
that contains this reference is still alive.
There's mathematical proof that you if you don't have 5 of those dead,
you're great to go and don't need to collect.
You still have to scan/mark the whole memory. Collecting unmarked memory
is the easy part that doesn't cost too much time.
Being flexible enough, you can skip 9 in 10 collections altogether imo
see this:
https://github.com/D-Programming-Language/druntime/pull/803
also mathematical proof is at page 154-183 of:
http://books.google.ca/books?id=b-XFrpBQ7d0C&lpg=PA119&pg=PA154#v=onepage&q&f=false
AFAICT your test case does not measure garbage collection, but manual
memory management using the GC as the memory manager. delete/free are
not meant to be called by user code as these are unsafe operations.