This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Again: Guile + Boehm's gc
Hi,
(BTW: I think it's safe to assume that the guile's
capturing main is going to be fixed. I almost made a patch last
night, but my conscience kicked in and I wrote instead. I think
that's the major "problem" with guile...)
I think we've probably followed similar logic to reach opposite
conclusions. I find it more difficult to keep track of how to
allocate which chunk of memory. You find it more difficult to mark
global variables.
Personally I avoid global variables like a plague. It's an alergic
reaction. With our crazy use of F77 common blocks I break in to hives
everytime I use a global. Marking it with protect/unprotect seems
natural, and not very obtrusive. On the other hand, I'd hate to have
to remember which malloc to use where.
>> I have. I wasn't making an idle speculation. Mixing malloc and
>> GC_malloc is a recipe for memory leaks.
>How so ?
Sticking pointers to malloced memory into GC_malloced structures, and
forgetting to free them. Yes... I've done that... (I'm not a
programmer, and I don't play one on television).
>> This is exactly the point about "special rules". You've traded a
>> system where you must remember not to place certain opaque types into
>> a global variable for a system where you have to remember which
>> pointers are malloced by which routine. If you use the wrong free, it
>> creates a bug that is *extremely* difficult to track down.
>The point is that THIS restriction is ALWAYS there...
Except in most languages there is only one standard way to allocate
memory (malloc in C, new in C++, whatchutalkinabout in fortran), and
IME special cases are pretty rare (ie shared memory). By requiring
GC_malloc in guile modules, you are requiring substantial chunks of
code to ignore the usual memory allocation routines. With the current
guile, I can write my glue code and be pretty oblivious to guile's GC.
The only time I have to worry about GC is if I take an SCM and stuff
it into a global. Clearly it's a matter of personal opinion, but for
me, that is "automatic". If I had to worry about which routine I used
to allocate memory, that would be "manual"
Cheers,
Clark