summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-08-12 11:30:30 -0700
committerAlex Sakhartchouk <alexst@google.com>2011-08-12 11:30:30 -0700
commit5c4369a3a1b19eaeabb044af2cdeef05474f9069 (patch)
tree37efb8a8c0473e672bbeeb705437784b0fdb3753
parent319680d6280bd8eb1eeecb6dfb8074dc42aaeec7 (diff)
downloadandroid_frameworks_rs-5c4369a3a1b19eaeabb044af2cdeef05474f9069.tar.gz
android_frameworks_rs-5c4369a3a1b19eaeabb044af2cdeef05474f9069.tar.bz2
android_frameworks_rs-5c4369a3a1b19eaeabb044af2cdeef05474f9069.zip
Fix to the memory leak problem.
Change-Id: I18dfa76ecae62ed5165415531adf3a13ad992b54
-rw-r--r--rsAllocation.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index f3e0c0a7..b59ade8d 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -58,6 +58,19 @@ void Allocation::updateCache() {
}
Allocation::~Allocation() {
+ if (mHal.state.hasReferences &&
+ (mHal.state.hasFaces || mHal.state.hasMipmaps)) {
+ LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!");
+ }
+
+ uint32_t elemCount = mHal.state.dimensionX;
+ if (mHal.state.dimensionY > 1) {
+ elemCount *= mHal.state.dimensionY;
+ }
+ if (mHal.state.dimensionZ > 1) {
+ elemCount *= mHal.state.dimensionZ;
+ }
+ decRefs(getPtr(), elemCount, 0);
mRSC->mHal.funcs.allocation.destroy(mRSC, this);
}
@@ -270,6 +283,9 @@ void Allocation::incRefs(const void *ptr, size_t ct, size_t startOff) const {
}
void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
+ if (!mHal.state.hasReferences || !getIsScript()) {
+ return;
+ }
const uint8_t *p = static_cast<const uint8_t *>(ptr);
const Element *e = mHal.state.type->getElement();
uint32_t stride = e->getSizeBytes();