6880903: G1: G1 reports incorrect Runtime.maxMemory()
G1 reports committed memory instead of reserved memory from the Runtime.maxMemory() method Reviewed-by: ysr, jmasa
This commit is contained in:
parent
d875a8e0f1
commit
8a125d9913
hotspot/src/share/vm
@ -2130,7 +2130,7 @@ size_t G1CollectedHeap::large_typearray_limit() {
|
||||
}
|
||||
|
||||
size_t G1CollectedHeap::max_capacity() const {
|
||||
return _g1_committed.byte_size();
|
||||
return g1_reserved_obj_bytes();
|
||||
}
|
||||
|
||||
jlong G1CollectedHeap::millis_since_last_gc() {
|
||||
|
@ -692,7 +692,7 @@ public:
|
||||
|
||||
// Reserved (g1 only; super method includes perm), capacity and the used
|
||||
// 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 used() const;
|
||||
// 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) {
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
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 survivor_max = survivor_space_max(g1h);
|
||||
max = subtract_up_to_zero(max, eden_max);
|
||||
@ -113,11 +113,12 @@ G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
|
||||
}
|
||||
|
||||
MemoryUsage G1EdenPool::get_memory_usage() {
|
||||
size_t maxSize = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = eden_space_committed();
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
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) :
|
||||
@ -129,11 +130,12 @@ G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
|
||||
}
|
||||
|
||||
MemoryUsage G1SurvivorPool::get_memory_usage() {
|
||||
size_t maxSize = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = survivor_space_committed();
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
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) :
|
||||
@ -145,9 +147,10 @@ G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
|
||||
}
|
||||
|
||||
MemoryUsage G1OldGenPool::get_memory_usage() {
|
||||
size_t maxSize = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = old_space_committed();
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
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:
|
||||
static size_t overall_used(G1CollectedHeap* g1h) {
|
||||
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_used(G1CollectedHeap* g1h);
|
||||
|
Loading…
x
Reference in New Issue
Block a user