Change GetFreeMemory to use the growth limit.
This makes more sense since it is what the allocator uses. Also fixed
somewhere where we were not properly passing in whether or not it was
a large object allocation.
Bug: 15327879
Change-Id: Ieab7af5427f5cdc2760390186b67e2c96d4bafa7
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index e03b6f7..a962f06 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1161,7 +1161,7 @@
}
ptr = TryToAllocate<true, true>(self, allocator, alloc_size, bytes_allocated, usable_size);
if (ptr == nullptr) {
- ThrowOutOfMemoryError(self, alloc_size, false);
+ ThrowOutOfMemoryError(self, alloc_size, allocator == kAllocatorTypeLOS);
}
return ptr;
}
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index e11671b..e568b36 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -408,7 +408,7 @@
// Implements java.lang.Runtime.freeMemory.
size_t GetFreeMemory() const {
- return GetTotalMemory() - num_bytes_allocated_.LoadSequentiallyConsistent();
+ return GetMaxMemory() - num_bytes_allocated_.LoadSequentiallyConsistent();
}
// get the space that corresponds to an object's address. Current implementation searches all