summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/gc/heap.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 419d5558a8..452980cf7a 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3154,8 +3154,12 @@ void Heap::ClearConcurrentGCRequest() {
}
void Heap::RequestConcurrentGC(Thread* self) {
- if (CanAddHeapTask(self) &&
- concurrent_gc_pending_.CompareExchangeStrongSequentiallyConsistent(false, true)) {
+ // If we don't have a started runtime, then we don't have a thread which is running the heap
+ // tasks. In this case, do the GC in the allocating thread to ensure that memory gets freed.
+ if (!Runtime::Current()->IsFinishedStarting()) {
+ CollectGarbageInternal(collector::kGcTypeFull, kGcCauseForAlloc, false);
+ } else if (CanAddHeapTask(self) &&
+ concurrent_gc_pending_.CompareExchangeStrongSequentiallyConsistent(false, true)) {
task_processor_->AddTask(self, new ConcurrentGCTask(NanoTime())); // Start straight away.
}
}