diff options
| author | Romain Guy <romainguy@google.com> | 2011-07-27 18:51:50 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2011-07-27 18:51:50 -0700 |
| commit | 65b345fa22b878e141b8fd8ece9c208df00fa40f (patch) | |
| tree | 587ba028a74320da19f8eeddbd4a2fb377e68cb4 /core/java/android/view/WindowManagerImpl.java | |
| parent | 6d7475d666baefaa3ba9f0dcee25238739454241 (diff) | |
Reclaim more memory, more often.
Yay.
Change-Id: I04557ad575c307a55088549f48f0e9ad994b7275
Diffstat (limited to 'core/java/android/view/WindowManagerImpl.java')
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index a451bb52204f..5ef4f3eb31e7 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -24,6 +24,9 @@ import android.util.AndroidRuntimeException; import android.util.Log; import android.view.inputmethod.InputMethodManager; +import java.io.FileDescriptor; +import java.io.FileOutputStream; +import java.io.PrintWriter; import java.util.HashMap; final class WindowLeaked extends AndroidRuntimeException { @@ -392,7 +395,7 @@ public class WindowManagerImpl implements WindowManager { leak.setStackTrace(root.getLocation().getStackTrace()); Log.e("WindowManager", leak.getMessage(), leak); } - + removeViewLocked(i); i--; count--; @@ -410,6 +413,59 @@ public class WindowManagerImpl implements WindowManager { } } + /** + * @hide + */ + public void trimLocalMemory() { + synchronized (this) { + if (mViews == null) return; + int count = mViews.length; + for (int i = 0; i < count; i++) { + mRoots[i].destroyHardwareLayers(); + } + } + } + + /** + * @hide + */ + public void dumpGfxInfo(FileDescriptor fd) { + FileOutputStream fout = new FileOutputStream(fd); + PrintWriter pw = new PrintWriter(fout); + try { + synchronized (this) { + if (mViews != null) { + pw.println("View hierarchy:"); + + final int count = mViews.length; + + int viewsCount = 0; + int displayListsSize = 0; + int[] info = new int[2]; + + for (int i = 0; i < count; i++) { + ViewRootImpl root = mRoots[i]; + root.dumpGfxInfo(pw, info); + + String name = root.getClass().getName() + '@' + + Integer.toHexString(hashCode()); + pw.printf(" %s: %d views, %.2f kB (display lists)\n", + name, info[0], info[1] / 1024.0f); + + viewsCount += info[0]; + displayListsSize += info[1]; + } + + pw.printf("\nTotal ViewRootImpl: %d\n", count); + pw.printf("Total Views: %d\n", viewsCount); + pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); + } + } + } finally { + pw.flush(); + } + } + public void setStoppedState(IBinder token, boolean stopped) { synchronized (this) { if (mViews == null) |
