3307 // java.lang.management.MemoryUsage API. 3308 // 3309 // Ideally, we would be able to set the default value of MaxMetaspaceSize in 3310 // globals.hpp to the aligned value, but this is not possible, since the 3311 // alignment depends on other flags being parsed. 3312 MaxMetaspaceSize = align_down_bounded(MaxMetaspaceSize, _reserve_alignment); 3313 3314 if (MetaspaceSize > MaxMetaspaceSize) { 3315 MetaspaceSize = MaxMetaspaceSize; 3316 } 3317 3318 MetaspaceSize = align_down_bounded(MetaspaceSize, _commit_alignment); 3319 3320 assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize"); 3321 3322 MinMetaspaceExpansion = align_down_bounded(MinMetaspaceExpansion, _commit_alignment); 3323 MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment); 3324 3325 CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment); 3326 set_compressed_class_space_size(CompressedClassSpaceSize); 3327 } 3328 3329 void Metaspace::global_initialize() { 3330 MetaspaceGC::initialize(); 3331 3332 #if INCLUDE_CDS 3333 if (DumpSharedSpaces) { 3334 MetaspaceShared::initialize_dumptime_shared_and_meta_spaces(); 3335 } else if (UseSharedSpaces) { 3336 // If any of the archived space fails to map, UseSharedSpaces 3337 // is reset to false. Fall through to the 3338 // (!DumpSharedSpaces && !UseSharedSpaces) case to set up class 3339 // metaspace. 3340 MetaspaceShared::initialize_runtime_shared_and_meta_spaces(); 3341 } 3342 3343 if (!DumpSharedSpaces && !UseSharedSpaces) 3344 #endif // INCLUDE_CDS 3345 { 3346 #ifdef _LP64 | 3307 // java.lang.management.MemoryUsage API. 3308 // 3309 // Ideally, we would be able to set the default value of MaxMetaspaceSize in 3310 // globals.hpp to the aligned value, but this is not possible, since the 3311 // alignment depends on other flags being parsed. 3312 MaxMetaspaceSize = align_down_bounded(MaxMetaspaceSize, _reserve_alignment); 3313 3314 if (MetaspaceSize > MaxMetaspaceSize) { 3315 MetaspaceSize = MaxMetaspaceSize; 3316 } 3317 3318 MetaspaceSize = align_down_bounded(MetaspaceSize, _commit_alignment); 3319 3320 assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize"); 3321 3322 MinMetaspaceExpansion = align_down_bounded(MinMetaspaceExpansion, _commit_alignment); 3323 MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment); 3324 3325 CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment); 3326 set_compressed_class_space_size(CompressedClassSpaceSize); 3327 3328 /* Initial virtual space size will be calculated at global_initialize() */ 3329 size_t min_metaspace_sz = 3330 VIRTUALSPACEMULTIPLIER * InitialBootClassLoaderMetaspaceSize; 3331 if (UseCompressedClassPointers) { 3332 if ((min_metaspace_sz + CompressedClassSpaceSize) > MaxMetaspaceSize) { 3333 if (min_metaspace_sz >= MaxMetaspaceSize) { 3334 vm_exit_during_initialization("MaxMetaspaceSize is too small."); 3335 } else { 3336 FLAG_SET_ERGO(size_t, CompressedClassSpaceSize, 3337 MaxMetaspaceSize - min_metaspace_sz); 3338 } 3339 } 3340 } else if (min_metaspace_sz >= MaxMetaspaceSize) { 3341 FLAG_SET_ERGO(size_t, InitialBootClassLoaderMetaspaceSize, 3342 min_metaspace_sz); 3343 } 3344 3345 } 3346 3347 void Metaspace::global_initialize() { 3348 MetaspaceGC::initialize(); 3349 3350 #if INCLUDE_CDS 3351 if (DumpSharedSpaces) { 3352 MetaspaceShared::initialize_dumptime_shared_and_meta_spaces(); 3353 } else if (UseSharedSpaces) { 3354 // If any of the archived space fails to map, UseSharedSpaces 3355 // is reset to false. Fall through to the 3356 // (!DumpSharedSpaces && !UseSharedSpaces) case to set up class 3357 // metaspace. 3358 MetaspaceShared::initialize_runtime_shared_and_meta_spaces(); 3359 } 3360 3361 if (!DumpSharedSpaces && !UseSharedSpaces) 3362 #endif // INCLUDE_CDS 3363 { 3364 #ifdef _LP64 |