[MLton] Extra GC pressure

Matthew Fluet fluet at tti-c.org
Fri Feb 23 06:18:12 PST 2007


>>> The idea being that if you have an SML object that is backed by a C 
>>> object (for example SQLite, GTK, etc), you can indicate to the GC how 
>>> much memory (approximately) the C-side is consuming. When you free 
>>> that memory, you tell the GC that the memory pressure has been 
>>> reduced. The goal of this is to help trigger a GC earlier to clean up 
>>> SML objects (and thus their attached C state).
>>
>> I can imagine the situation you describe, but have you encountered it 
>> in practice?
> 
> Not yet.
> 
> However, I've also not written a program in SML that uses this many C 
> structures. Actually, this can be done without any changes to MLton, so 
> that's probably the best route. I am imagining that I keep a global 
> 'cUsage' counter that is incremented/decremented on allocation/free. 
> When an increment makes it too large, trigger a GC, look at the value 
> after GC and set the limit (for another GC) to twice that.

That seems like a reasonable way to go.





More information about the MLton mailing list