Mercurial > hg > graal-compiler
comparison src/share/vm/memory/collectorPolicy.cpp @ 12838:85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
Reviewed-by: brutisso, jmasa, coleenp
author | stefank |
---|---|
date | Mon, 07 Oct 2013 15:51:08 +0200 |
parents | 087f02e22fc2 |
children | 4288e54fd145 |
comparison
equal
deleted
inserted
replaced
12837:82af7d7a0128 | 12838:85c1ca43713f |
---|---|
45 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" | 45 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" |
46 #endif // INCLUDE_ALL_GCS | 46 #endif // INCLUDE_ALL_GCS |
47 | 47 |
48 // CollectorPolicy methods. | 48 // CollectorPolicy methods. |
49 | 49 |
50 // Align down. If the aligning result in 0, return 'alignment'. | |
51 static size_t restricted_align_down(size_t size, size_t alignment) { | |
52 return MAX2(alignment, align_size_down_(size, alignment)); | |
53 } | |
54 | |
55 void CollectorPolicy::initialize_flags() { | 50 void CollectorPolicy::initialize_flags() { |
56 assert(_max_alignment >= _min_alignment, | 51 assert(_max_alignment >= _min_alignment, |
57 err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT, | 52 err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT, |
58 _max_alignment, _min_alignment)); | 53 _max_alignment, _min_alignment)); |
59 assert(_max_alignment % _min_alignment == 0, | 54 assert(_max_alignment % _min_alignment == 0, |
62 | 57 |
63 if (MaxHeapSize < InitialHeapSize) { | 58 if (MaxHeapSize < InitialHeapSize) { |
64 vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); | 59 vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); |
65 } | 60 } |
66 | 61 |
67 // Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will | |
68 // override if MaxMetaspaceSize was set on the command line or not. | |
69 // This information is needed later to conform to the specification of the | |
70 // java.lang.management.MemoryUsage API. | |
71 // | |
72 // Ideally, we would be able to set the default value of MaxMetaspaceSize in | |
73 // globals.hpp to the aligned value, but this is not possible, since the | |
74 // alignment depends on other flags being parsed. | |
75 MaxMetaspaceSize = restricted_align_down(MaxMetaspaceSize, _max_alignment); | |
76 | |
77 if (MetaspaceSize > MaxMetaspaceSize) { | |
78 MetaspaceSize = MaxMetaspaceSize; | |
79 } | |
80 | |
81 MetaspaceSize = restricted_align_down(MetaspaceSize, _min_alignment); | |
82 | |
83 assert(MetaspaceSize <= MaxMetaspaceSize, "Must be"); | |
84 | |
85 MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _min_alignment); | |
86 MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _min_alignment); | |
87 | |
88 MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment); | 62 MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment); |
89 | |
90 assert(MetaspaceSize % _min_alignment == 0, "metapace alignment"); | |
91 assert(MaxMetaspaceSize % _max_alignment == 0, "maximum metaspace alignment"); | |
92 if (MetaspaceSize < 256*K) { | |
93 vm_exit_during_initialization("Too small initial Metaspace size"); | |
94 } | |
95 } | 63 } |
96 | 64 |
97 void CollectorPolicy::initialize_size_info() { | 65 void CollectorPolicy::initialize_size_info() { |
98 // User inputs from -mx and ms must be aligned | 66 // User inputs from -mx and ms must be aligned |
99 _min_heap_byte_size = align_size_up(Arguments::min_heap_size(), _min_alignment); | 67 _min_heap_byte_size = align_size_up(Arguments::min_heap_size(), _min_alignment); |