This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Making GC aware of overall allocation?
- To: Lars Arvestad <arve at nada dot kth dot se>
- Subject: Re: Making GC aware of overall allocation?
- From: Miroslav Silovic <silovic at zesoi dot fer dot hr>
- Date: 02 Nov 1999 11:02:28 +0100
- Cc: guile at sourceware dot cygnus dot com
- References: <yue1za9e2nt.fsf@turing.nada.kth.se>
Lars Arvestad <arve@nada.kth.se> writes:
> So my question is: Is there a way to make GC aware of how much memory
> is allocated by the process and react to that?
Use scm_must_malloc instead of malloc in your C code. Make sure that
the free function for your smobs returns the accurate value for the
memory freed (i.e. matching the ammount allocated with
scm_must_malloc), otherwise your gc will get very confused.
> Of course, I was naive about how to take advantage of the GC. But I
> claim this is a real problem since there will be many more naive users
> using Guile. If Guile could set up a safe, comfortable GC for the C
> extension writer, I am sure our favourite extension language would get
> an edge on other systems.
I made the same mistake while writing SART. Switch to scm_must_malloc
didn't take too long, though. My suggestion would be to put a big,
glaring warning sign somewhere in 'how to write SMOBs' tutorial.
--
How to eff the ineffable?