This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Making GC aware of overall allocation?


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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]