|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-09-17 13:52:44
On 09/17/07 03:30, Achilleas Margaritis wrote:
> Larry Evans wrote:
>> On 09/16/07 16:56, Achilleas Margaritis wrote:
[snip]
>> How does this collector determine the location of pointers on the stack
>> and within the heap?
>
> An internal bit map is used as a pointer database. Each bit represents
> one pointer location in memory.
>
> When the class gc_ptr<T> is created, the bit that corresponds to the
> pointer's address is set.
>
> When a pointer is destroyed, the same bit is reset.
>
> The bitmap is organized in pages of 4K and allocated dynamically.
>
> The collector sweeps unused pages at collection time.
So the essential difference from the Boehm conservative collector:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gcdescr.html
is in the mark phase where, instead of:
Any bit patterns that represent addresses inside heap objects managed
by the collector are viewed as pointers.
your collector would have:
Any memory location contained in the pointer database must be
pointer.
Hence, during the scan of memory, if a memory location is in the
pointer database, that memory location is dereferenced to arrive
at another memory location which is then marked and then
the memory from that location to that location + size (where size
is stored somewhere else) is scanned.
Is that about right?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk