From 183e1380cef0f63610497abed01e16036a2ea2d4 Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 9 Oct 2019 13:41:18 -0700 Subject: Improve dumping of display list memory usage The first step of improving is measuring. So measure better. Bug: 138856108 Test: dump Change-Id: I076b904a1f0dfb209622c76bcb8778a10cd2b7db --- graphics/java/android/graphics/RenderNode.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/RenderNode.java b/graphics/java/android/graphics/RenderNode.java index 0e635c774c84..17e3b4465130 100644 --- a/graphics/java/android/graphics/RenderNode.java +++ b/graphics/java/android/graphics/RenderNode.java @@ -1380,7 +1380,22 @@ public final class RenderNode { * @return Approximate memory usage in bytes. */ public @BytesLong long computeApproximateMemoryUsage() { - return nGetDebugSize(mNativeRenderNode); + return nGetUsageSize(mNativeRenderNode); + } + + /** + * Gets the approximate amount of memory allocated for the RenderNode for debug purposes. + * Does not include the memory allocated by any child RenderNodes nor any bitmaps, only the + * memory allocated for this RenderNode and any data it owns. + * + * The difference between this and {@link #computeApproximateMemoryUsage()} is this includes + * memory allocated but not used. In particular structures such as DisplayLists are similar + * to things like ArrayLists - they need to resize as commands are added to them. As such, + * memory used can be less than memory allocated. + * + * @hide */ + public @BytesLong long computeApproximateMemoryAllocated() { + return nGetAllocatedSize(mNativeRenderNode); } /** @@ -1485,7 +1500,8 @@ public final class RenderNode { private static native void nOutput(long renderNode); - private static native int nGetDebugSize(long renderNode); + private static native int nGetUsageSize(long renderNode); + private static native int nGetAllocatedSize(long renderNode); private static native void nRequestPositionUpdates(long renderNode, PositionUpdateListener callback); -- cgit v1.2.3-59-g8ed1b