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]

Making GC aware of overall allocation?



I have run into a problem with large objects on the C heap.  I have a
C extension that work with large data structures (they are complex,
you don't just sizeof() them) that have been put in smob:s. The smobs
makes it possible to gc them, of course, which has the advantage that I
can interupt my lengthy C coded algorithms and not loose pointers to
allocated memory. Actually, another advantage that should not be
underestimated is that it makes error control easier. In case of an
error (anywhere, really, such as in the middle of setting up a complex 
datastructure), my C routines can simply return to scheme without
having to deallocate a lot of various structures.

Unfortunately, since the footprint of the smobs is very small, the GC
system will not detect cases when the main memory is exhausted from
several large data structures and needs a GC. I was bitten by this of
course...  

My solution is to put a (gc) here and there in my code, but that is
far from optimal. It means that I unnecessarily scan the heap many
times and also that I put some of the deallocation burden back on the
programmer, which is not what you expect from a GC system.

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?

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.

	Best regards,
	Lars

-- 
Lars Arvestad               Dept. of Numerical Analysis and Computing Science
                       Royal Institute of Technology (KTH), Stockholm, Sweden

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