MSc Defence by Mikkel Willén

Title

Programmer-Directed Region Management in ReML

Abstract

Region-based memory management, as implemented in the MLKit compiler for Standard ML, assigns each heap-allocated value to a region and reclaims memory through constant-time region deallocation.  When the built-in garbage collector is disabled, programmers must cooperate with the region system to keep memory bounded, using reset primitives to reclaim region contents in long-running loops.  However, the existing primitives can only reset all regions appearing in a value's type, cannot accept explicit region variables, and provide no mechanism for inspecting region state at runtime. This forces programmers into fixed-interval collection strategies and unsafe force-resets, with no way to make data-driven reclamation decisions from within the running program.  We present three contributions that address these limitations in ReML, a Standard ML extension with explicit region annotations. First, we extend the MLKit's compiler so that the reset primitives accept explicit region variables as additional arguments, and we extend the foreign function interface to pass explicit regions pointers to C functions. Second, we implement two SML modules that build on these extensions: a Region module that provides typed access to perregion metadata at runtime, and a Size combinator library for computing the memory footprint of Standard ML values as they are laid out in regions. Third, we apply these tools to a chat service that processes packets in a long-running loop with the built-in garbage collector disabled, demonstrating adaptive threshold-based garbage collection where the program decides when to reclaim memory based on measured region usage. The case study achieves bounded memory usage with runtime comparable to MLKit's built-in garbage collector.

Supervisor

Martin Elsman, DIKU

External examiner

Peter Sestoft, ITU