mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8222462: Introduce CollectedHeap::unused()
Reviewed-by: stefank, eosterlund
This commit is contained in:
parent
72491e961c
commit
2accc59e60
9 changed files with 25 additions and 6 deletions
|
@ -81,6 +81,11 @@ void GCHeapLog::log_heap(CollectedHeap* heap, bool before) {
|
|||
st.print_cr("}");
|
||||
}
|
||||
|
||||
size_t CollectedHeap::unused() const {
|
||||
MutexLocker ml(Heap_lock);
|
||||
return capacity() - used();
|
||||
}
|
||||
|
||||
VirtualSpaceSummary CollectedHeap::create_heap_space_summary() {
|
||||
size_t capacity_in_words = capacity() / HeapWordSize;
|
||||
|
||||
|
|
|
@ -210,6 +210,9 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
|||
virtual size_t capacity() const = 0;
|
||||
virtual size_t used() const = 0;
|
||||
|
||||
// Returns unused capacity.
|
||||
virtual size_t unused() const;
|
||||
|
||||
// Return "true" if the part of the heap that allocates Java
|
||||
// objects has reached the maximal committed limit that it can
|
||||
// reach, without a garbage collection.
|
||||
|
|
|
@ -100,6 +100,10 @@ size_t ZCollectedHeap::used() const {
|
|||
return _heap.used();
|
||||
}
|
||||
|
||||
size_t ZCollectedHeap::unused() const {
|
||||
return _heap.unused();
|
||||
}
|
||||
|
||||
bool ZCollectedHeap::is_maximal_no_gc() const {
|
||||
// Not supported
|
||||
ShouldNotReachHere();
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
virtual size_t max_capacity() const;
|
||||
virtual size_t capacity() const;
|
||||
virtual size_t used() const;
|
||||
virtual size_t unused() const;
|
||||
|
||||
virtual bool is_maximal_no_gc() const;
|
||||
virtual bool is_in(const void* p) const;
|
||||
|
|
|
@ -133,6 +133,10 @@ size_t ZHeap::used() const {
|
|||
return _page_allocator.used();
|
||||
}
|
||||
|
||||
size_t ZHeap::unused() const {
|
||||
return _page_allocator.unused();
|
||||
}
|
||||
|
||||
size_t ZHeap::allocated() const {
|
||||
return _page_allocator.allocated();
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
size_t used_high() const;
|
||||
size_t used_low() const;
|
||||
size_t used() const;
|
||||
size_t unused() const;
|
||||
size_t allocated() const;
|
||||
size_t reclaimed() const;
|
||||
|
||||
|
|
|
@ -133,6 +133,11 @@ size_t ZPageAllocator::used() const {
|
|||
return _used;
|
||||
}
|
||||
|
||||
size_t ZPageAllocator::unused() const {
|
||||
const ssize_t unused = (ssize_t)_physical.capacity() - (ssize_t)_used - (ssize_t)_max_reserve;
|
||||
return unused > 0 ? (size_t)unused : 0;
|
||||
}
|
||||
|
||||
size_t ZPageAllocator::allocated() const {
|
||||
return _allocated;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
size_t used_high() const;
|
||||
size_t used_low() const;
|
||||
size_t used() const;
|
||||
size_t unused() const;
|
||||
size_t allocated() const;
|
||||
size_t reclaimed() const;
|
||||
|
||||
|
|
|
@ -508,12 +508,7 @@ JVM_END
|
|||
|
||||
JVM_ENTRY_NO_ENV(jlong, JVM_FreeMemory(void))
|
||||
JVMWrapper("JVM_FreeMemory");
|
||||
CollectedHeap* ch = Universe::heap();
|
||||
size_t n;
|
||||
{
|
||||
MutexLocker x(Heap_lock);
|
||||
n = ch->capacity() - ch->used();
|
||||
}
|
||||
size_t n = Universe::heap()->unused();
|
||||
return convert_size_t_to_jlong(n);
|
||||
JVM_END
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue