GC conservatism -- again

Vladimir Panteleev vladimir at thecybershadow.net
Tue Dec 28 19:13:10 PST 2010


On Tue, 28 Dec 2010 20:07:03 +0200, Ulrik Mikaelsson  
<ulrik.mikaelsson at gmail.com> wrote:

> Considering the "don't count on collection"-principle I mentioned
> above, is this approach safe, especially if other parts of the program
> grows large in address-space?

There is a simple formula with which you can calculate the probability of  
a stray pointer keeping your object uncollected. The probability of an  
object of size M containing random data to contain a pointer inside an  
object of size N is:
P(M,N) = 1 - (1 - N/2^32)^(M/4)
Let's suppose that we want to calculate at which point does there become a  
danger for a Data object to be erroneously not collected. Taking an  
approximation of a DataWrapper and a Data object taking about 32 bytes of  
heap, the point at which the probability goes over 0.5 is when the total  
size of pointers in the managed heap goes over 372 MB. If you have over  
300 MB of pointers in your managed heap, your program may need a bit of  
restructuring anyway :)

Some more details about the formula in my graduation thesis paper, page 30:
http://thecybershadow.net/d/Memory_Management_in_the_D_Programming_Language.pdf

-- 
Best regards,
  Vladimir                            mailto:vladimir at thecybershadow.net


More information about the Digitalmars-d mailing list