VirtualSpaceList // Returns a root chunk. // Chunk gets one of four colors. // Adjusts commit counters. Observes Limits. MetaChunk* allocate_root_chunk_space() // purge empty nodes void purge(); ------------------------------------------------------------------------ ChunkManager // 1:1 direct get get_chunk(level, preferred_color) // get a chunk from the freelist, with allowed tolerance (e.g. return a chunk // smaller or larger than level). get_fuzzy(level, preferred_color) // get a chunk from the freelist, splitting a larger chunk if needed split_larger_and_get_chunk(level, preferred_color) // Allocate space for a new root chunk from the virtualspacelist // split it, add unused parts to freelist // return requested chunk refill_and_get_chunk(level) public // Uncommit all chunks, depending on size rules. To be called // during metaspace gc. void uncommit_free_chunks(); ------------------------------------------------------------------------- ??? :: https://ci.sapmachine.io/ https://bit.ly/2Xmi7BT --------------------- Idea: chunk coloring. Split free chunks into 4 groups, and code preference into ClassLoaderMetaspace // Counters need to be accessible from both backingSpace and from Metachunk. class Accountant reserved commit // check limits (MaxMetaspaceSize and GC threshold). // if not even min is possible, returns 0 // if min is possible but not preferred, returns min and increases commit counter // if preferred is possible, returns preferred and increases commit counter size_t try_inc_committed(size_t min, size_t preferred) - all under expand lock // check limits (MaxMetaspaceSize and GC threshold). // if not even min is possible, returns 0 // if min is possible but not preferred, returns min and increases commit counter // if preferred is possible, returns preferred and increases commit counter size_t try_inc_committed_locked(size_t min, size_t preferred) - all under expand lock void dec_committed(size_t size) - all under expand lock get_reserved_nolock() reserved_lock() get_comitted_nolock() comitted_lock() ClassSpaceAccountant NonClassSpaceAccountant.