In SableVM, thread specific memory is managed independently from shared memory. SableVM allocates thread structures on thread creation but does not release them at thread death. Instead, it manages a free list to recycle this memory on future thread creation.
Java stacks are growing structures; a memory block is allocated at thread creation, and if later the stack proves too small, the memory block is expanded, possibly moving it to another location to keep the stack contiguous and avoid fragmentation.
SableVM also manages class loader specific memory independently from other memory. Each class loader has it own memory manager that allocates memory (from the system) in relatively big chunks, then redistributes this memory is smaller fragments. This has many advantages.
It allows the allocation of many small memory blocks without the usual
memory space overhead, as
malloc() would use additional
memory space to store the size of each allocated block in prevision of
future free() calls. In the class loader specific memory
category, smaller fragments will only be returned to the system as a
group (in case of class unloading), so we need not keep track of
individual fragment sizes.
As a corollary, class unloading is more efficient using a dedicated memory manager than using regular malloc() and free() calls, as there is no need to incrementally aggregate small memory segments, as would happen with a sequence of free() calls.
Using dedicated memory managers allows class parsing and decoding in one pass without memory overhead, by allocating many small memory blocks. This is usually not feasible, as it is not possible to estimate the memory requirement for storing internal class information before the end of the first pass.
Finally, and importantly, a dedicated memory manager allows for irregular memory management strategies: it is possible to return sub-areas of an allocated block to the memory manager, if these sub-areas are known not to be used. We take advantage of this to improve the representation of interface method lookup tables7.