aboutsummaryrefslogtreecommitdiff
path: root/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2013-07-18 11:51:10 -0700
committerKevin Jin <kjin@google.com>2013-07-18 11:51:10 -0700
commit0b9344441daed36d371df59ca4735d1e0e008189 (patch)
tree31a27477a44cc1ecc153bdc844afefe26ef9ce58 /src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
parentb18bb64ed9513bedf8222e6915abb5164e9108f9 (diff)
downloaddroiddriver-0b9344441daed36d371df59ca4735d1e0e008189.tar.gz
fix memory leak in Contexts UiElement cache
UiElement values need to be WeakReference as well Change-Id: I31f6e833216154a3d3da7ebabc856d8ce8221631
Diffstat (limited to 'src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java')
-rw-r--r--src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java b/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
index b171ac6..cfd1488 100644
--- a/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
+++ b/src/com/google/android/droiddriver/uiautomation/UiAutomationContext.java
@@ -33,8 +33,9 @@ import java.util.Map;
public class UiAutomationContext {
private final Instrumentation instrumentation;
private final InputInjector injector;
+ // Maybe we should use Cache instead of Map on memory-constrained devices
private final Map<AccessibilityNodeInfo, UiAutomationElement> map = new MapMaker().weakKeys()
- .makeMap();
+ .weakValues().makeMap();
UiAutomationContext(Instrumentation instrumentation) {
this.instrumentation = Preconditions.checkNotNull(instrumentation);
@@ -51,7 +52,7 @@ public class UiAutomationContext {
}
public UiAutomation getUiAutomation() {
- return instrumentation.getUiAutomation();
+ return instrumentation.getUiAutomation();
}
public InputInjector getInjector() {