On Tue, 28 Dec 2010 20:07:03 +0200, Ulrik Mikaelsson <[email protected]> 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:[email protected]

Reply via email to