Delete almost correct CHECK
The bytes_allocated + freed_bytes >= bytes_allocated_before_gc
CHECK could fail if we expand space use as a result of copying,
and perhaps for other reasons. Delete it, and have the later code
deal with the fact that it may not hold.
Test: Build and boot AOSP.
Bug: 194263989
Change-Id: I9188a7cd13661c16b1b69a90d1f03d60548db217
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 21e9c31..7706a5c 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3637,9 +3637,9 @@
current_gc_iteration_.GetFreedRevokeBytes();
// Bytes allocated will shrink by freed_bytes after the GC runs, so if we want to figure out
// how many bytes were allocated during the GC we need to add freed_bytes back on.
- CHECK_GE(bytes_allocated + freed_bytes, bytes_allocated_before_gc);
- const size_t bytes_allocated_during_gc = bytes_allocated + freed_bytes -
- bytes_allocated_before_gc;
+ // Almost always bytes_allocated + freed_bytes >= bytes_allocated_before_gc.
+ const size_t bytes_allocated_during_gc =
+ UnsignedDifference(bytes_allocated + freed_bytes, bytes_allocated_before_gc);
// Calculate when to perform the next ConcurrentGC.
// Estimate how many remaining bytes we will have when we need to start the next GC.
size_t remaining_bytes = bytes_allocated_during_gc;