[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage Collection questions

From: Michael Livshin
Subject: Re: Garbage Collection questions
Date: 14 May 2001 01:13:25 +0300
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft)

Sam Tregar <address@hidden> writes:

> 1) Is it possible to examine/walk the GC mark tree from C code?  That
> would be a huge help in debugging and might also help me in other ways too
> perverse to get into here.

no, sorry.

there are debugging aids (like the --enable-debug-freelist configure
flag) that let you catch GC-related mistakes as early as possible.

but it does seem to me that the GC got you more scared than it should
have.  it's actually very simple to tame if you stick by a very small
amount of very simple rules.

[ hey, it's a key feature of Guile that it has maximally trouble-free
  interaction with C code! ]

> 2) Under what circumstances do I need to protect an SCM?  Say, for
> instance I write:
>   result = scm_cons(a, b);
> Do I need to do something with result to keep it from getting GC'd at some
> arbitrary point in the future?

the GC magically scans two areas: the C stack and the registers.  if
`result' is a static/global variable (i.e. sits neither on the stack
nor in the registers), then GC won't retain the result of cons, so you
should explicitly tell the GC to spare it.

see `scm_[un]protect_object' & `scm_permanent_object'.

[ I'm too sleepy right now, so if I try to describe them I'll likely
  mislead you.  will follow up tomorrow... ]

good sigmonster, have a cookie.

Who's afraid of the garbage collector?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]