[Gc] Heap traversal

Ludovic Courtès ludo at gnu.org
Fri Oct 2 01:54:42 PDT 2009


Hello,

The former GC of Guile provided information about the (approximate)
number of live objects of each data type:

--8<---------------cut here---------------start------------->8---
guile> (pp (gc-live-object-stats))
(("dynamic-state" . 2)
 ("complex number" . 7)
 ("thread" . 1)
 ("frame" . 19)
 ("macro" . 72)
 ("srcprops" . 2898)

[...]

 ("cons (non-immediate car)" . 41614)
 ("jmpbuffer" . 1))
--8<---------------cut here---------------end--------------->8---

With libgc, heap traversal can be done with ‘GC_apply_to_all_blocks ()’.
This is what GCJ does
(http://google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#nnPz_KYt5WI/com/avtrex/test/memory/GCInfoC.cc&q=GC_enumerator&l=264).

The problem is that ‘GC_apply_to_all_blocks ()’, ‘struct hblk’, and the
macros and functions that manipulate blocks and block headers are all
private.

What would be the best way to expose just enough of these internals so
that one can write this kind of heap traversing code?

Thanks,
Ludo’.



More information about the Gc mailing list