From 3b91fccc0a83c6c9ce7fef484495f863d739baff Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 25 Apr 2017 16:31:20 -0700 Subject: [PATCH] Only log a few types of GC causes for the blocking cases There are various types like debugger and GetObjectsAllocated that can cause spam if we log all the blocking calls. In practice, these are only used from tools and should not cause jank. Bug: 37275712 Test: test-art-host Change-Id: I3a6854d37a6e83c91e9cc8bcb76103e2498bc3b6 --- runtime/gc/heap.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 64dce5f4e..be7e85654 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -3517,7 +3517,13 @@ collector::GcType Heap::WaitForGcToCompleteLocked(GcCause cause, Thread* self) { // is not the heap task daemon thread, it's considered as a // blocking GC (i.e., blocking itself). running_collection_is_blocking_ = true; - VLOG(gc) << "Starting a blocking GC " << cause; + // Don't log fake "GC" types that are only used for debugger or hidden APIs. If we log these, + // it results in log spam. kGcCauseExplicit is already logged in LogGC, so avoid it here too. + if (cause == kGcCauseForAlloc || + cause == kGcCauseForNativeAlloc || + cause == kGcCauseDisableMovingGc) { + VLOG(gc) << "Starting a blocking GC " << cause; + } } return last_gc_type; } -- 2.11.0