diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-12-16 10:35:19 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-02-19 12:38:42 -0800 |
commit | c0a7e2bb1609da40ec67cb7e00c918637c610897 (patch) | |
tree | 61325a88af96f0e64bf68cfe32351127426aae28 /runtime/gc | |
parent | 3f43b5f4881db5a1f7bd13a095f720b7c1ddba6a (diff) | |
download | art-c0a7e2bb1609da40ec67cb7e00c918637c610897.zip art-c0a7e2bb1609da40ec67cb7e00c918637c610897.tar.gz art-c0a7e2bb1609da40ec67cb7e00c918637c610897.tar.bz2 |
Do GC for alloc for unstarted runtimes
Currently, concurrent GC requests are ignored for unstarted runtimes.
The new logic is to do a GC for alloc in RequestConcurrentGC if the
runtime is not started. This reduces the java heap size in dex2oat.
Change-Id: I8d4364a4e3537013b27390bb22a6f64aab58c924
Diffstat (limited to 'runtime/gc')
-rw-r--r-- | runtime/gc/heap.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 419d555..452980c 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. } } |