Skip to content
Snippets Groups Projects
Commit 9785506d authored by Oz Linden's avatar Oz Linden
Browse files

merge changes for storm-1651

parents e8ac2947 89797263
No related branches found
No related tags found
No related merge requests found
......@@ -1821,6 +1821,7 @@ void LLPrivateMemoryPool::LLChunkHashElement::remove(LLPrivateMemoryPool::LLMemo
//class LLPrivateMemoryPoolManager
//--------------------------------------------------------------------
LLPrivateMemoryPoolManager* LLPrivateMemoryPoolManager::sInstance = NULL ;
std::vector<LLPrivateMemoryPool*> LLPrivateMemoryPoolManager::sDanglingPoolList ;
LLPrivateMemoryPoolManager::LLPrivateMemoryPoolManager(BOOL enabled, U32 max_pool_size)
{
......@@ -1848,7 +1849,7 @@ LLPrivateMemoryPoolManager::~LLPrivateMemoryPoolManager()
S32 k = 0 ;
for(mem_allocation_info_t::iterator iter = sMemAllocationTracker.begin() ; iter != sMemAllocationTracker.end() ; ++iter)
{
llinfos << k++ << ", " << iter->second << llendl ;
llinfos << k++ << ", " << (U32)iter->first << " : " << iter->second << llendl ;
}
sMemAllocationTracker.clear() ;
}
......@@ -1868,7 +1869,17 @@ LLPrivateMemoryPoolManager::~LLPrivateMemoryPoolManager()
{
if(mPoolList[i])
{
delete mPoolList[i] ;
if(mPoolList[i]->isEmpty())
{
delete mPoolList[i] ;
}
else
{
//can not delete this pool because it has alloacted memory to be freed.
//move it to the dangling list.
sDanglingPoolList.push_back(mPoolList[i]) ;
}
mPoolList[i] = NULL ;
}
}
......@@ -2004,6 +2015,32 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
}
else
{
if(!sInstance) //the private memory manager is destroyed, try the dangling list
{
for(S32 i = 0 ; i < sDanglingPoolList.size(); i++)
{
if(sDanglingPoolList[i]->findChunk((char*)addr))
{
sDanglingPoolList[i]->freeMem(addr) ;
if(sDanglingPoolList[i]->isEmpty())
{
delete sDanglingPoolList[i] ;
if(i < sDanglingPoolList.size() - 1)
{
sDanglingPoolList[i] = sDanglingPoolList[sDanglingPoolList.size() - 1] ;
}
sDanglingPoolList.pop_back() ;
}
addr = NULL ;
break ;
}
}
}
llassert_always(!addr) ; //addr should be release before hitting here!
free(addr) ;
}
}
......
......@@ -400,6 +400,7 @@ class LL_COMMON_API LLPrivateMemoryPoolManager
BOOL mPrivatePoolEnabled;
U32 mMaxPrivatePoolSize;
static std::vector<LLPrivateMemoryPool*> sDanglingPoolList ;
public:
//debug and statistics info.
void updateStatistics() ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment