提交 bc0d9e36 编写于 作者: T tonyp

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
上级 1f7260b7
...@@ -2130,7 +2130,7 @@ size_t G1CollectedHeap::large_typearray_limit() { ...@@ -2130,7 +2130,7 @@ size_t G1CollectedHeap::large_typearray_limit() {
} }
size_t G1CollectedHeap::max_capacity() const { size_t G1CollectedHeap::max_capacity() const {
return _g1_committed.byte_size(); return g1_reserved_obj_bytes();
} }
jlong G1CollectedHeap::millis_since_last_gc() { jlong G1CollectedHeap::millis_since_last_gc() {
......
...@@ -692,7 +692,7 @@ public: ...@@ -692,7 +692,7 @@ public:
// Reserved (g1 only; super method includes perm), capacity and the used // Reserved (g1 only; super method includes perm), capacity and the used
// portion in bytes. // portion in bytes.
size_t g1_reserved_obj_bytes() { return _g1_reserved.byte_size(); } size_t g1_reserved_obj_bytes() const { return _g1_reserved.byte_size(); }
virtual size_t capacity() const; virtual size_t capacity() const;
virtual size_t used() const; virtual size_t used() const;
// This should be called when we're not holding the heap lock. The // This should be called when we're not holding the heap lock. The
......
...@@ -96,7 +96,7 @@ size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) { ...@@ -96,7 +96,7 @@ size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) {
// See the comment at the top of g1MemoryPool.hpp // See the comment at the top of g1MemoryPool.hpp
size_t G1MemoryPoolSuper::old_space_max(G1CollectedHeap* g1h) { size_t G1MemoryPoolSuper::old_space_max(G1CollectedHeap* g1h) {
size_t max = g1h->g1_reserved_obj_bytes(); size_t max = overall_max(g1h);
size_t eden_max = eden_space_max(g1h); size_t eden_max = eden_space_max(g1h);
size_t survivor_max = survivor_space_max(g1h); size_t survivor_max = survivor_space_max(g1h);
max = subtract_up_to_zero(max, eden_max); max = subtract_up_to_zero(max, eden_max);
...@@ -113,11 +113,12 @@ G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) : ...@@ -113,11 +113,12 @@ G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
} }
MemoryUsage G1EdenPool::get_memory_usage() { MemoryUsage G1EdenPool::get_memory_usage() {
size_t maxSize = max_size(); size_t initial_sz = initial_size();
size_t used = used_in_bytes(); size_t max_sz = max_size();
size_t committed = eden_space_committed(); size_t used = used_in_bytes();
size_t committed = eden_space_committed();
return MemoryUsage(initial_size(), used, committed, maxSize); return MemoryUsage(initial_sz, used, committed, max_sz);
} }
G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
...@@ -129,11 +130,12 @@ G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : ...@@ -129,11 +130,12 @@ G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
} }
MemoryUsage G1SurvivorPool::get_memory_usage() { MemoryUsage G1SurvivorPool::get_memory_usage() {
size_t maxSize = max_size(); size_t initial_sz = initial_size();
size_t used = used_in_bytes(); size_t max_sz = max_size();
size_t committed = survivor_space_committed(); size_t used = used_in_bytes();
size_t committed = survivor_space_committed();
return MemoryUsage(initial_size(), used, committed, maxSize); return MemoryUsage(initial_sz, used, committed, max_sz);
} }
G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
...@@ -145,9 +147,10 @@ G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : ...@@ -145,9 +147,10 @@ G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
} }
MemoryUsage G1OldGenPool::get_memory_usage() { MemoryUsage G1OldGenPool::get_memory_usage() {
size_t maxSize = max_size(); size_t initial_sz = initial_size();
size_t used = used_in_bytes(); size_t max_sz = max_size();
size_t committed = old_space_committed(); size_t used = used_in_bytes();
size_t committed = old_space_committed();
return MemoryUsage(initial_size(), used, committed, maxSize); return MemoryUsage(initial_sz, used, committed, max_sz);
} }
...@@ -137,6 +137,9 @@ protected: ...@@ -137,6 +137,9 @@ protected:
static size_t overall_used(G1CollectedHeap* g1h) { static size_t overall_used(G1CollectedHeap* g1h) {
return g1h->used_unlocked(); return g1h->used_unlocked();
} }
static size_t overall_max(G1CollectedHeap* g1h) {
return g1h->g1_reserved_obj_bytes();
}
static size_t eden_space_committed(G1CollectedHeap* g1h); static size_t eden_space_committed(G1CollectedHeap* g1h);
static size_t eden_space_used(G1CollectedHeap* g1h); static size_t eden_space_used(G1CollectedHeap* g1h);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册