From 81df4adad0094ee5d4d92d49fdce4e19d3ccea39 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 22 Oct 2014 17:31:12 -0700 Subject: Only allow once GC request at a time. There is no reason to allow multiple, allocating threads may have multiple GC requests before the GC starts. Bug: 17942071 (cherry picked from commit 71891f9da2fbcb865931da70ae759032e6698106) Change-Id: I5e2162373bcef1027eb71e5b1699186ff015f92d --- libart/src/main/java/java/lang/Daemons.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java index a414c49..4f8285c 100644 --- a/libart/src/main/java/java/lang/Daemons.java +++ b/libart/src/main/java/java/lang/Daemons.java @@ -317,11 +317,9 @@ public final class Daemons { private static class GCDaemon extends Daemon { private static final GCDaemon INSTANCE = new GCDaemon(); - private int count = 0; public void requestGC() { synchronized (this) { - ++count; notify(); } } @@ -330,11 +328,8 @@ public final class Daemons { while (isRunning()) { try { synchronized (this) { - // Wait until a request comes in, unless we have a pending request. - while (count == 0) { - wait(); - } - --count; + // Wait until a request comes in. + wait(); } VMRuntime.getRuntime().concurrentGC(); } catch (InterruptedException ignored) { -- cgit v1.1