summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChris Craik <ccraik@android.com>2014-03-25 13:21:01 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-25 13:21:01 -0700
commit4118480aabb4a7b332e289ebb71d2e4f9bc05d7e (patch)
tree8a1efeafedb47d05ddef7a423f3af677db311cab /libs
parentc1d863e7a4b55f8e583067eebaffc6686723d7ab (diff)
parent80470cdf6c6995f4afe8d5e2c4b6e898625173fb (diff)
downloadframeworks_base-4118480aabb4a7b332e289ebb71d2e4f9bc05d7e.zip
frameworks_base-4118480aabb4a7b332e289ebb71d2e4f9bc05d7e.tar.gz
frameworks_base-4118480aabb4a7b332e289ebb71d2e4f9bc05d7e.tar.bz2
am 80470cdf: Merge "Solve three memory leaks related to PatchCache"
* commit '80470cdf6c6995f4afe8d5e2c4b6e898625173fb': Solve three memory leaks related to PatchCache
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Patch.cpp1
-rw-r--r--libs/hwui/PatchCache.cpp17
2 files changed, 16 insertions, 2 deletions
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index b2148b0..442e9ba 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -36,6 +36,7 @@ Patch::Patch(): vertices(NULL), verticesCount(0), indexCount(0), hasEmptyQuads(f
}
Patch::~Patch() {
+ delete[] vertices;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp
index 8a44604..2f2debc 100644
--- a/libs/hwui/PatchCache.cpp
+++ b/libs/hwui/PatchCache.cpp
@@ -119,6 +119,17 @@ void PatchCache::remove(Vector<patch_pair_t>& patchesToRemove, Res_png_9patch* p
void PatchCache::removeDeferred(Res_png_9patch* patch) {
Mutex::Autolock _l(mLock);
+
+ // Assert that patch is not already garbage
+ size_t count = mGarbage.size();
+ for (size_t i = 0; i < count; i++) {
+ if (patch == mGarbage[i]) {
+ patch = NULL;
+ break;
+ }
+ }
+ LOG_ALWAYS_FATAL_IF(patch == NULL);
+
mGarbage.push(patch);
}
@@ -143,8 +154,8 @@ void PatchCache::clearGarbage() {
for (size_t i = 0; i < patchesToRemove.size(); i++) {
const patch_pair_t& pair = patchesToRemove[i];
- // Add a new free block to the list
- const Patch* patch = pair.getSecond();
+ // Release the patch and mark the space in the free list
+ Patch* patch = pair.getSecond();
BufferBlock* block = new BufferBlock(patch->offset, patch->getSize());
block->next = mFreeBlocks;
mFreeBlocks = block;
@@ -152,6 +163,7 @@ void PatchCache::clearGarbage() {
mSize -= patch->getSize();
mCache.remove(*pair.getFirst());
+ delete patch;
}
#if DEBUG_PATCHES
@@ -216,6 +228,7 @@ void PatchCache::setupMesh(Patch* newMesh, TextureVertex* vertices) {
} else {
mFreeBlocks = block->next;
}
+ delete block;
} else {
// Resize the block now that it's occupied
block->offset += size;