summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2022-12-21 15:15:54 -0800
committer Hans Boehm <hboehm@google.com> 2023-01-03 16:42:30 +0000
commit6163b5f652726b58c7d5943a27e9be8297cd2012 (patch)
tree08acd1a3f2edd7e0e5c2e0ffb5c64cefbc58a397
parentd3389a31c8beba969238693ef6573096360526b5 (diff)
Add explanation for region space fragmentation
Explain, both in the error message and in a more detailed comment, what it means to run out of region space due to fragmentation. Bug: 262916014 Test: Treehugger Change-Id: If7060464cc6b0f5309e2afdf9704fc540e6985f8
-rw-r--r--runtime/gc/space/region_space.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/gc/space/region_space.cc b/runtime/gc/space/region_space.cc
index 76816ddd2e..60141d656b 100644
--- a/runtime/gc/space/region_space.cc
+++ b/runtime/gc/space/region_space.cc
@@ -741,10 +741,19 @@ bool RegionSpace::LogFragmentationAllocFailure(std::ostream& os,
max_contiguous_allocation = std::min(max_contiguous_allocation,
regions_free_for_alloc * kRegionSize);
if (failed_alloc_bytes > max_contiguous_allocation) {
+ // Region space does not normally fragment in the conventional sense. However we can run out
+ // of region space prematurely if we have many threads, each with a partially committed TLAB.
+ // The whole TLAB uses up region address space, but we only count the section that was
+ // actually given to the thread so far as allocated. For unlikely allocation request sequences
+ // involving largish objects that don't qualify for large objects space, we may also be unable
+ // to fully utilize entire TLABs, and thus generate enough actual fragmentation to get
+ // here. This appears less likely, since we usually reuse sufficiently large TLAB "tails"
+ // that are no longer needed.
os << "; failed due to fragmentation (largest possible contiguous allocation "
- << max_contiguous_allocation << " bytes). Number of "
- << PrettySize(kRegionSize)
- << " sized free regions are: " << regions_free_for_alloc;
+ << max_contiguous_allocation << " bytes). Number of " << PrettySize(kRegionSize)
+ << " sized free regions are: " << regions_free_for_alloc
+ << ". Likely cause: (1) Too much memory in use, and "
+ << "(2) many threads or many larger objects of the wrong kind";
return true;
}
// Caller's job to print failed_alloc_bytes.