[gclist] Boehm's collector and "dynamic roots"

Fergus Henderson fjh@cs.mu.oz.au
Thu, 1 Mar 2001 17:32:07 +1100


On 01-Mar-2001, Ji-Yong D. Chung <virtualcyber@erols.com> wrote:
>     I am wondering if there is any way to cause
> the collector to scan only to the top of MY OWN
> stack, rather than the whole 200k.
> 
>     For this, it seems that I need to implement
> additional interfaces that could add
> what one may call "dynamic" roots -- roots
> whose size will change when I push
> my stack.
>
>     Has anyone encountered a similar problem
> before, and know of a relatively simple solution
> to this problem?

Use the GC_push_other_roots() hook, which is declared in gc_priv.h:

extern void (*GC_push_other_roots)();
                        /* Push system or application specific roots    */
                        /* onto the mark stack.  In some environments   */
                        /* (e.g. threads environments) this is          */
                        /* predfined to be non-zero.  A client supplied */
                        /* replacement should also call the original    */
                        /* function.                                    */

This will get called whenever a collection occurs.

In your function, you can call GC_push_all() or GC_push_all_stack()
to register your stack.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.