From d24b8183b93e781080b2c16c487e60d51c12da31 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 10 Feb 2009 15:44:00 -0800 Subject: auto import from //branches/cupcake/...@130745 --- tools/preload/MemoryUsage.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/preload/MemoryUsage.java') diff --git a/tools/preload/MemoryUsage.java b/tools/preload/MemoryUsage.java index 89717eb..e5dfb2a 100644 --- a/tools/preload/MemoryUsage.java +++ b/tools/preload/MemoryUsage.java @@ -32,6 +32,9 @@ class MemoryUsage implements Serializable { private static final long serialVersionUID = 0; static final MemoryUsage NOT_AVAILABLE = new MemoryUsage(); + + static int errorCount = 0; + static final int MAXIMUM_ERRORS = 10; // give up after this many fails final int nativeSharedPages; final int javaSharedPages; @@ -160,6 +163,13 @@ class MemoryUsage implements Serializable { * Measures memory usage for the given class. */ static MemoryUsage forClass(String className) { + + // This is a coarse approximation for determining that no device is connected, + // or that the communication protocol has changed, but we'll keep going and stop whining. + if (errorCount >= MAXIMUM_ERRORS) { + return NOT_AVAILABLE; + } + MeasureWithTimeout measurer = new MeasureWithTimeout(className); new Thread(measurer).start(); @@ -237,6 +247,7 @@ class MemoryUsage implements Serializable { if (line == null || !line.startsWith("DECAFBAD,")) { System.err.println("Got bad response for " + className + ": " + line); + errorCount += 1; return NOT_AVAILABLE; } -- cgit v1.1