diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/gc/allocator/rosalloc.cc | 28 | ||||
| -rw-r--r-- | runtime/gc/heap.cc | 4 |
2 files changed, 19 insertions, 13 deletions
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index 40186f8f26..2e4475f225 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -2068,26 +2068,30 @@ void RosAlloc::LogFragmentationAllocFailure(std::ostream& os, size_t failed_allo size_t largest_continuous_free_pages = 0; WriterMutexLock wmu(self, bulk_free_lock_); MutexLock mu(self, lock_); + uint64_t total_free = 0; for (FreePageRun* fpr : free_page_runs_) { largest_continuous_free_pages = std::max(largest_continuous_free_pages, fpr->ByteSize(this)); + total_free += fpr->ByteSize(this); } + size_t required_bytes = 0; + const char* new_buffer_msg = ""; if (failed_alloc_bytes > kLargeSizeThreshold) { // Large allocation. - size_t required_bytes = RoundUp(failed_alloc_bytes, kPageSize); - if (required_bytes > largest_continuous_free_pages) { - os << "; failed due to fragmentation (required continguous free " - << required_bytes << " bytes where largest contiguous free " - << largest_continuous_free_pages << " bytes)"; - } + required_bytes = RoundUp(failed_alloc_bytes, kPageSize); } else { // Non-large allocation. - size_t required_bytes = numOfPages[SizeToIndex(failed_alloc_bytes)] * kPageSize; - if (required_bytes > largest_continuous_free_pages) { - os << "; failed due to fragmentation (required continguous free " - << required_bytes << " bytes for a new buffer where largest contiguous free " - << largest_continuous_free_pages << " bytes)"; - } + required_bytes = numOfPages[SizeToIndex(failed_alloc_bytes)] * kPageSize; + new_buffer_msg = " for a new buffer"; + } + if (required_bytes > largest_continuous_free_pages) { + os << "; failed due to fragmentation (" + << "required contiguous free " << required_bytes << " bytes" << new_buffer_msg + << ", largest contiguous free " << largest_continuous_free_pages << " bytes" + << ", total free pages " << total_free << " bytes" + << ", space footprint " << footprint_ << " bytes" + << ", space max capacity " << max_capacity_ << " bytes" + << ")" << std::endl; } } diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 5c219cc871..8ff5e5a062 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -1326,7 +1326,9 @@ void Heap::ThrowOutOfMemoryError(Thread* self, size_t byte_count, AllocatorType std::ostringstream oss; size_t total_bytes_free = GetFreeMemory(); oss << "Failed to allocate a " << byte_count << " byte allocation with " << total_bytes_free - << " free bytes and " << PrettySize(GetFreeMemoryUntilOOME()) << " until OOM"; + << " free bytes and " << PrettySize(GetFreeMemoryUntilOOME()) << " until OOM," + << " max allowed footprint " << max_allowed_footprint_ << ", growth limit " + << growth_limit_; // If the allocation failed due to fragmentation, print out the largest continuous allocation. if (total_bytes_free >= byte_count) { space::AllocSpace* space = nullptr; |