[libui/sf] Add total buffer size tracing to SF
Adds a line for "Total Buffer Size" to systrace, corresponding to the
combined size of all buffers allocated in SF's process.
Test: manual, verified that line appears on systrace and matches dumpsys
Bug: 131244853
Change-Id: Ifdd3151516dd5010494c9619281a0f0b71767e9c
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 5a67dc4..0861a1f 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -60,6 +60,15 @@
GraphicBufferAllocator::~GraphicBufferAllocator() {}
+size_t GraphicBufferAllocator::getTotalSize() const {
+ Mutex::Autolock _l(sLock);
+ size_t total = 0;
+ for (size_t i = 0; i < sAllocList.size(); ++i) {
+ total += sAllocList.valueAt(i).size;
+ }
+ return total;
+}
+
void GraphicBufferAllocator::dump(std::string& result) const {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);