comparison src/share/vm/services/g1MemoryPool.cpp @ 1092:ed52bcc32739

6880903: G1: G1 reports incorrect Runtime.maxMemory() Summary: G1 reports committed memory instead of reserved memory from the Runtime.maxMemory() method Reviewed-by: ysr, jmasa
author tonyp
date Fri, 04 Dec 2009 07:44:35 -0500
parents db0d5eba9d20
children afc30fccf324
comparison
equal deleted inserted replaced
1091:6aa7255741f3 1092:ed52bcc32739
94 return used; 94 return used;
95 } 95 }
96 96
97 // See the comment at the top of g1MemoryPool.hpp 97 // See the comment at the top of g1MemoryPool.hpp
98 size_t G1MemoryPoolSuper::old_space_max(G1CollectedHeap* g1h) { 98 size_t G1MemoryPoolSuper::old_space_max(G1CollectedHeap* g1h) {
99 size_t max = g1h->g1_reserved_obj_bytes(); 99 size_t max = overall_max(g1h);
100 size_t eden_max = eden_space_max(g1h); 100 size_t eden_max = eden_space_max(g1h);
101 size_t survivor_max = survivor_space_max(g1h); 101 size_t survivor_max = survivor_space_max(g1h);
102 max = subtract_up_to_zero(max, eden_max); 102 max = subtract_up_to_zero(max, eden_max);
103 max = subtract_up_to_zero(max, survivor_max); 103 max = subtract_up_to_zero(max, survivor_max);
104 return max; 104 return max;
111 eden_space_max(g1h), /* max_size */ 111 eden_space_max(g1h), /* max_size */
112 false /* support_usage_threshold */) { 112 false /* support_usage_threshold */) {
113 } 113 }
114 114
115 MemoryUsage G1EdenPool::get_memory_usage() { 115 MemoryUsage G1EdenPool::get_memory_usage() {
116 size_t maxSize = max_size(); 116 size_t initial_sz = initial_size();
117 size_t used = used_in_bytes(); 117 size_t max_sz = max_size();
118 size_t committed = eden_space_committed(); 118 size_t used = used_in_bytes();
119 size_t committed = eden_space_committed();
119 120
120 return MemoryUsage(initial_size(), used, committed, maxSize); 121 return MemoryUsage(initial_sz, used, committed, max_sz);
121 } 122 }
122 123
123 G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : 124 G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
124 G1MemoryPoolSuper(g1h, 125 G1MemoryPoolSuper(g1h,
125 "G1 Survivor", 126 "G1 Survivor",
127 survivor_space_max(g1h), /* max_size */ 128 survivor_space_max(g1h), /* max_size */
128 false /* support_usage_threshold */) { 129 false /* support_usage_threshold */) {
129 } 130 }
130 131
131 MemoryUsage G1SurvivorPool::get_memory_usage() { 132 MemoryUsage G1SurvivorPool::get_memory_usage() {
132 size_t maxSize = max_size(); 133 size_t initial_sz = initial_size();
133 size_t used = used_in_bytes(); 134 size_t max_sz = max_size();
134 size_t committed = survivor_space_committed(); 135 size_t used = used_in_bytes();
136 size_t committed = survivor_space_committed();
135 137
136 return MemoryUsage(initial_size(), used, committed, maxSize); 138 return MemoryUsage(initial_sz, used, committed, max_sz);
137 } 139 }
138 140
139 G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : 141 G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
140 G1MemoryPoolSuper(g1h, 142 G1MemoryPoolSuper(g1h,
141 "G1 Old Gen", 143 "G1 Old Gen",
143 old_space_max(g1h), /* max_size */ 145 old_space_max(g1h), /* max_size */
144 true /* support_usage_threshold */) { 146 true /* support_usage_threshold */) {
145 } 147 }
146 148
147 MemoryUsage G1OldGenPool::get_memory_usage() { 149 MemoryUsage G1OldGenPool::get_memory_usage() {
148 size_t maxSize = max_size(); 150 size_t initial_sz = initial_size();
149 size_t used = used_in_bytes(); 151 size_t max_sz = max_size();
150 size_t committed = old_space_committed(); 152 size_t used = used_in_bytes();
153 size_t committed = old_space_committed();
151 154
152 return MemoryUsage(initial_size(), used, committed, maxSize); 155 return MemoryUsage(initial_sz, used, committed, max_sz);
153 } 156 }