[MLton] Extra GC pressure
Wesley W. Terpstra
wesley at terpstra.ca
Wed Feb 21 18:20:29 PST 2007
At the moment, the GC only cleans up memory when the ML heap is full
or explicitly requested. Memory usage from C data structures is not
counted towards when the RAM is exhausted. How hard would it be to
add MLton.GC.{add,sub}Memory that kept track of additional memory
pressure in the GC?
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).
A better interface would probably be MLton.GC.alloc <n> which returns
an opaque type. When that type is GC'd, the <n> bytes are
additionally subtracted from the extra memory pressure counter.
Good/bad idea? Easy/hard to implement idea?
More information about the MLton
mailing list