OSDN Git Service

Only log a few types of GC causes for the blocking cases
authorMathieu Chartier <mathieuc@google.com>
Tue, 25 Apr 2017 23:31:20 +0000 (16:31 -0700)
committerMathieu Chartier <mathieuc@google.com>
Tue, 25 Apr 2017 23:38:42 +0000 (16:38 -0700)
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

index 64dce5f..be7e856 100644 (file)
@@ -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;
 }