From 8000d0694bc34bc17d869da546d8ff8790ae7be4 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 26 Mar 2013 18:15:35 -0700 Subject: [PATCH] make sure to unlock the screenshot's buffer on destruction this fixes a memory leak on various devices Bug: 8475134 Change-Id: I25924674c803a0cb22371a95c60664c36acb0340 --- include/gui/SurfaceComposerClient.h | 1 + libs/gui/SurfaceComposerClient.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index 23655c7ec..6bf5b47f9 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -170,6 +170,7 @@ private: public: ScreenshotClient(); + ~ScreenshotClient(); // frees the previous screenshot and capture a new one status_t update(const sp& display); diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index ec46fce40..f345df88b 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -627,6 +627,10 @@ ScreenshotClient::ScreenshotClient() memset(&mBuffer, 0, sizeof(mBuffer)); } +ScreenshotClient::~ScreenshotClient() { + ScreenshotClient::release(); +} + sp ScreenshotClient::getCpuConsumer() const { if (mCpuConsumer == NULL) { mCpuConsumer = new CpuConsumer(1);