summaryrefslogtreecommitdiff
path: root/tools/preload/MemoryUsage.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
commitd24b8183b93e781080b2c16c487e60d51c12da31 (patch)
treefbb89154858984eb8e41556da7e9433040d55cd4 /tools/preload/MemoryUsage.java
parentf1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff)
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'tools/preload/MemoryUsage.java')
-rw-r--r--tools/preload/MemoryUsage.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/preload/MemoryUsage.java b/tools/preload/MemoryUsage.java
index 89717eb34f78..e5dfb2ac4c0b 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;
}