comparison src/share/vm/memory/metaspace.cpp @ 8791:47902e9acb3a

Merge
author stefank
date Fri, 22 Mar 2013 10:32:21 +0100
parents 82ab039b9680 7f0cb32dd233
children 6574f999e0cf
comparison
equal deleted inserted replaced
8756:686916dc0439 8791:47902e9acb3a
1101 } 1101 }
1102 return delta_words; 1102 return delta_words;
1103 } 1103 }
1104 1104
1105 bool MetaspaceGC::should_expand(VirtualSpaceList* vsl, size_t word_size) { 1105 bool MetaspaceGC::should_expand(VirtualSpaceList* vsl, size_t word_size) {
1106 // If the user wants a limit, impose one.
1107 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize) &&
1108 MetaspaceAux::reserved_in_bytes() >= MaxMetaspaceSize) {
1109 return false;
1110 }
1106 1111
1107 // Class virtual space should always be expanded. Call GC for the other 1112 // Class virtual space should always be expanded. Call GC for the other
1108 // metadata virtual space. 1113 // metadata virtual space.
1109 if (vsl == Metaspace::class_space_list()) return true; 1114 if (vsl == Metaspace::class_space_list()) return true;
1110
1111 // If the user wants a limit, impose one.
1112 size_t max_metaspace_size_words = MaxMetaspaceSize / BytesPerWord;
1113 size_t metaspace_size_words = MetaspaceSize / BytesPerWord;
1114 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize) &&
1115 vsl->capacity_words_sum() >= max_metaspace_size_words) {
1116 return false;
1117 }
1118 1115
1119 // If this is part of an allocation after a GC, expand 1116 // If this is part of an allocation after a GC, expand
1120 // unconditionally. 1117 // unconditionally.
1121 if(MetaspaceGC::expand_after_GC()) { 1118 if(MetaspaceGC::expand_after_GC()) {
1122 return true; 1119 return true;
1123 } 1120 }
1121
1122 size_t metaspace_size_words = MetaspaceSize / BytesPerWord;
1124 1123
1125 // If the capacity is below the minimum capacity, allow the 1124 // If the capacity is below the minimum capacity, allow the
1126 // expansion. Also set the high-water-mark (capacity_until_GC) 1125 // expansion. Also set the high-water-mark (capacity_until_GC)
1127 // to that minimum capacity so that a GC will not be induced 1126 // to that minimum capacity so that a GC will not be induced
1128 // until that minimum capacity is exceeded. 1127 // until that minimum capacity is exceeded.
1309 if (PrintGCDetails && Verbose) { 1308 if (PrintGCDetails && Verbose) {
1310 size_t new_capacity_until_GC = MetaspaceGC::capacity_until_GC_in_bytes(); 1309 size_t new_capacity_until_GC = MetaspaceGC::capacity_until_GC_in_bytes();
1311 gclog_or_tty->print_cr(" metaspace HWM: %.1fK", new_capacity_until_GC / (double) K); 1310 gclog_or_tty->print_cr(" metaspace HWM: %.1fK", new_capacity_until_GC / (double) K);
1312 } 1311 }
1313 } 1312 }
1314 assert(vsl->used_bytes_sum() == used_after_gc && 1313 assert(used_after_gc <= vsl->capacity_bytes_sum(),
1315 used_after_gc <= vsl->capacity_bytes_sum(),
1316 "sanity check"); 1314 "sanity check");
1317 1315
1318 } 1316 }
1319 1317
1320 // Metadebug methods 1318 // Metadebug methods
1970 gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this); 1968 gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
1971 } 1969 }
1972 } 1970 }
1973 1971
1974 SpaceManager::~SpaceManager() { 1972 SpaceManager::~SpaceManager() {
1973 // This call this->_lock which can't be done while holding expand_lock()
1974 const size_t in_use_before = sum_capacity_in_chunks_in_use();
1975
1975 MutexLockerEx fcl(SpaceManager::expand_lock(), 1976 MutexLockerEx fcl(SpaceManager::expand_lock(),
1976 Mutex::_no_safepoint_check_flag); 1977 Mutex::_no_safepoint_check_flag);
1977 1978
1978 ChunkManager* chunk_manager = vs_list()->chunk_manager(); 1979 ChunkManager* chunk_manager = vs_list()->chunk_manager();
1979 1980
1987 // Mangle freed memory. 1988 // Mangle freed memory.
1988 NOT_PRODUCT(mangle_freed_chunks();) 1989 NOT_PRODUCT(mangle_freed_chunks();)
1989 1990
1990 // Have to update before the chunks_in_use lists are emptied 1991 // Have to update before the chunks_in_use lists are emptied
1991 // below. 1992 // below.
1992 chunk_manager->inc_free_chunks_total(sum_capacity_in_chunks_in_use(), 1993 chunk_manager->inc_free_chunks_total(in_use_before,
1993 sum_count_in_chunks_in_use()); 1994 sum_count_in_chunks_in_use());
1994 1995
1995 // Add all the chunks in use by this space manager 1996 // Add all the chunks in use by this space manager
1996 // to the global list of free chunks. 1997 // to the global list of free chunks.
1997 1998