From b7a6c4340a35b7cc4ceeeccf6cc01ed82c99a8ba Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 2 Nov 2009 14:25:10 -0800 Subject: Fix some leaks. This fixes the major malloc memory leak in allApps. Still tracking some much more minor issues. --- libs/rs/rsAllocation.cpp | 2 ++ libs/rs/rsContext.cpp | 3 +++ libs/rs/rsObjectBase.cpp | 1 + libs/rs/rsSimpleMesh.cpp | 2 ++ libs/rs/rsType.cpp | 1 + 5 files changed, 9 insertions(+) diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index b7d1297..2cbfe17 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -52,6 +52,8 @@ Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc) Allocation::~Allocation() { + free(mPtr); + mPtr = NULL; } void Allocation::setCpuWritable(bool) diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index eb388af..961ec0b 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -350,6 +350,7 @@ void * Context::threadProc(void *vrsc) rsc->deinitEGL(); pthread_mutex_unlock(&gInitMutex); + rsc->mObjDestroy.mNeedToEmpty = true; rsc->objDestroyOOBRun(); LOGV("RS Thread exited"); return NULL; @@ -421,6 +422,7 @@ Context::~Context() mIO.shutdown(); int status = pthread_join(mThreadId, &res); + mObjDestroy.mNeedToEmpty = true; objDestroyOOBRun(); // Global structure cleanup. @@ -431,6 +433,7 @@ Context::~Context() if (!gThreadTLSKeyCount) { pthread_key_delete(gThreadTLSKey); } + mDev = NULL; } pthread_mutex_unlock(&gInitMutex); diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index 0008ea4..1b442ba 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -39,6 +39,7 @@ ObjectBase::~ObjectBase() rsAssert(!mUserRefCount); rsAssert(!mSysRefCount); remove(); + delete[] mName; } void ObjectBase::dumpLOGV(const char *op) const diff --git a/libs/rs/rsSimpleMesh.cpp b/libs/rs/rsSimpleMesh.cpp index b082fd7..434a35f 100644 --- a/libs/rs/rsSimpleMesh.cpp +++ b/libs/rs/rsSimpleMesh.cpp @@ -99,6 +99,8 @@ SimpleMeshContext::SimpleMeshContext() SimpleMeshContext::~SimpleMeshContext() { + delete[] mVertexTypes; + delete[] mVertexBuffers; } diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index ddaa2f0..0eb4111 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -57,6 +57,7 @@ TypeState::TypeState() TypeState::~TypeState() { + delete[] mLODs; } size_t Type::getOffsetForFace(uint32_t face) const -- cgit v1.1