Re: my ongoing fantasy of garbage collected C programming



On Tue, 5 Aug 2008, Britton Kerin wrote:


I've tried several times now to get Hans-Boehm
(http://www.hpl.hp.com/personal/Hans_Boehm/gc/) working with gtk, but so
far no luck.  I found all the stuff about how to build glib to be GC
friendly and set env vars and such, and then I rebuild almost all of the
lib stack on top of it (except atk and the X libs themselves). I still
end up with strange failures and seg faults that go away if I just
remove -lgc from the link flags.  I don't free anything by hand so its
got to be something the GC is doing.

I'm hoping that the presence of the gc-friendly build support in glib
means that somebody knows how to make this work. I would really love to
know how to do it. I won't go into the different gc builds and such that
I've tried unless someone is interested.

AFAIK, no one has tried to make boehm GC really work with glib & gtk+
programs so far. The "gc friendly" mode that glib has in general just
zeros-out certain memory portions before calling free(), so GC-alike
leak detectors like e.g. valgrind can do a more accurate job.

Depending on how clever your GC implementation is, I'd actually expect
quite some real world problems with it trying to "collect" glib
memory. E.g. GLib only stores pointers into the _middle_ of fundamental
GType nodes (not the node start) and with GSlice provides its own
allocator that cannot be replaced with GC collection (the memory pages
allocated by gslice.c:allocator_memalign are also not pointed to
directly, a pointer to an admin structure at the page tail is kept
instead).

Thanks,
Britton

---
ciaoTJ


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