src/hotspot/share/memory/metaspace/spaceManager.cpp
branchstuefe-new-metaspace-branch
changeset 58382 2e16658b7776
parent 58228 6e61beb13680
child 58475 e3aa9f95b85e
equal deleted inserted replaced
58381:5f5558a1a113 58382:2e16658b7776
   270     // Since we did not hit the commit limit, the current chunk must have been too small.
   270     // Since we did not hit the commit limit, the current chunk must have been too small.
   271     assert(current_chunk()->free_words() < raw_word_size, "Sanity");
   271     assert(current_chunk()->free_words() < raw_word_size, "Sanity");
   272 
   272 
   273     DEBUG_ONLY(InternalStats::inc_num_allocs_failed_chunk_too_small();)
   273     DEBUG_ONLY(InternalStats::inc_num_allocs_failed_chunk_too_small();)
   274 
   274 
   275     // Under certain conditions we can just attempt to enlarge the chunk.
   275     // Under certain conditions we can just attempt to enlarge the chunk - fusing it with its follower
   276     // - obviously, this only works for non-root chunks which are leader of their buddy pair.
   276     // chunk to produce a chunk double the size (level decreased by 1).
   277     // - only if doubling chunk size would actually help - if the requested size does not fit into
   277     // 0) only if it is not switched off
   278     //     the enlarged chunk either, better just attempt to allocate a new fitting chunk.
   278     // 1) obviously, this only works for non-root chunks
   279     // - below a certain chunk size to not blow up memory usage unnecessarily.
   279     // 2) ... which are leader of their buddy pair.
   280     if (Settings::enlarge_chunks_in_place() &&
   280     // 3) only if the requested allocation would fit into a thus enlarged chunk
   281         current_chunk()->is_root_chunk() == false &&
   281     // 4) do not grow memory faster than what the chunk allocation strategy would allow
   282         current_chunk()->is_leader() &&
   282     // 5) as a safety feature, only below a certain limit
   283         current_chunk()->word_size() + current_chunk()->free_words() >= requested_word_size &&
   283     if (Settings::enlarge_chunks_in_place() &&              // 0
   284         current_chunk()->word_size() <= Settings::enlarge_chunks_in_place_max_word_size())
   284         current_chunk()->is_root_chunk() == false &&        // 1
       
   285         current_chunk()->is_leader() &&                     // 2
       
   286         current_chunk()->word_size() + current_chunk()->free_words() >= requested_word_size &&      // 3
       
   287         _chunk_alloc_sequence->get_next_chunk_level(_chunks.size()) <= current_chunk()->level() &&  // 4
       
   288         current_chunk()->word_size() <= Settings::enlarge_chunks_in_place_max_word_size())          // 5
   285     {
   289     {
   286 
   290 
   287       if (_chunk_manager->attempt_enlarge_chunk(current_chunk())) {
   291       if (_chunk_manager->attempt_enlarge_chunk(current_chunk())) {
   288 
   292 
   289         // Re-attempt allocation.
   293         // Re-attempt allocation.