Dragged in a bunch of alignment fixes from LL. Should allow disabling of tcmalloc on windows/linux32 if such is ever implemented.
This commit is contained in:
@@ -67,6 +67,17 @@ BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
|
||||
LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sMemAllocationTracker;
|
||||
#endif
|
||||
|
||||
void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
|
||||
{
|
||||
#ifdef SHOW_ASSERT
|
||||
// Redundant, place to set breakpoints.
|
||||
if (ptr%alignment!=0)
|
||||
{
|
||||
llwarns << "alignment check failed" << llendl;
|
||||
}
|
||||
llassert(ptr%alignment==0);
|
||||
#endif
|
||||
}
|
||||
//static
|
||||
void LLMemory::initClass()
|
||||
{
|
||||
@@ -246,21 +257,6 @@ U32 LLMemory::getAllocatedMemKB()
|
||||
return sAllocatedMemInKB ;
|
||||
}
|
||||
|
||||
void* ll_allocate (size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
llwarns << "Null allocation" << llendl;
|
||||
}
|
||||
void *p = malloc(size);
|
||||
if (p == NULL)
|
||||
{
|
||||
LLMemory::freeReserve();
|
||||
llerrs << "Out of memory Error" << llendl;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(LL_WINDOWS)
|
||||
@@ -1415,7 +1411,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
|
||||
to_log = false ;
|
||||
}
|
||||
|
||||
return (char*)malloc(size) ;
|
||||
return (char*)ll_aligned_malloc_16(size) ;
|
||||
}
|
||||
|
||||
return p ;
|
||||
@@ -1434,7 +1430,7 @@ void LLPrivateMemoryPool::freeMem(void* addr)
|
||||
|
||||
if(!chunk)
|
||||
{
|
||||
free(addr) ; //release from heap
|
||||
ll_aligned_free_16(addr) ; //release from heap
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1558,7 +1554,7 @@ LLPrivateMemoryPool::LLMemoryChunk* LLPrivateMemoryPool::addChunk(S32 chunk_inde
|
||||
|
||||
mReservedPoolSize += preferred_size + overhead ;
|
||||
|
||||
char* buffer = (char*)malloc(preferred_size + overhead) ;
|
||||
char* buffer = (char*)ll_aligned_malloc_16(preferred_size + overhead) ;
|
||||
if(!buffer)
|
||||
{
|
||||
return NULL ;
|
||||
@@ -1626,7 +1622,7 @@ void LLPrivateMemoryPool::removeChunk(LLMemoryChunk* chunk)
|
||||
mReservedPoolSize -= chunk->getBufferSize() ;
|
||||
|
||||
//release memory
|
||||
free(chunk->getBuffer()) ;
|
||||
ll_aligned_free_16(chunk->getBuffer()) ;
|
||||
}
|
||||
|
||||
U16 LLPrivateMemoryPool::findHashKey(const char* addr)
|
||||
@@ -1970,7 +1966,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size,
|
||||
|
||||
if(!poolp)
|
||||
{
|
||||
p = (char*)malloc(size) ;
|
||||
p = (char*)ll_aligned_malloc_16(size) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1999,7 +1995,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
return (char*)malloc(size) ;
|
||||
return (char*)ll_aligned_malloc_16(size) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2024,7 +2020,7 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
|
||||
{
|
||||
if(!sPrivatePoolEnabled)
|
||||
{
|
||||
free(addr) ; //private pool is disabled.
|
||||
ll_aligned_free_16(addr) ; //private pool is disabled.
|
||||
}
|
||||
else if(!sInstance) //the private memory manager is destroyed, try the dangling list
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user