MAINT-8091 Removed deprecated and unused private memory pooling

master
Andrey Kleshchev 2018-01-30 14:03:26 +00:00
parent b0dedf0b68
commit 6e445e82e2
13 changed files with 40 additions and 2164 deletions

File diff suppressed because it is too large Load Diff

View File

@ -356,327 +356,6 @@ private:
static BOOL sEnableMemoryFailurePrevention;
};
//
//class LLPrivateMemoryPool defines a private memory pool for an application to use, so the application does not
//need to access the heap directly fro each memory allocation. Throught this, the allocation speed is faster,
//and reduces virtaul address space gragmentation problem.
//Note: this class is thread-safe by passing true to the constructor function. However, you do not need to do this unless
//you are sure the memory allocation and de-allocation will happen in different threads. To make the pool thread safe
//increases allocation and deallocation cost.
//
class LL_COMMON_API LLPrivateMemoryPool
{
friend class LLPrivateMemoryPoolManager ;
public:
class LL_COMMON_API LLMemoryBlock //each block is devided into slots uniformly
{
public:
LLMemoryBlock() ;
~LLMemoryBlock() ;
void init(char* buffer, U32 buffer_size, U32 slot_size) ;
void setBuffer(char* buffer, U32 buffer_size) ;
char* allocate() ;
void freeMem(void* addr) ;
bool empty() {return !mAllocatedSlots;}
bool isFull() {return mAllocatedSlots == mTotalSlots;}
bool isFree() {return !mTotalSlots;}
U32 getSlotSize()const {return mSlotSize;}
U32 getTotalSlots()const {return mTotalSlots;}
U32 getBufferSize()const {return mBufferSize;}
char* getBuffer() const {return mBuffer;}
//debug use
void resetBitMap() ;
private:
char* mBuffer;
U32 mSlotSize ; //when the block is not initialized, it is the buffer size.
U32 mBufferSize ;
U32 mUsageBits ;
U8 mTotalSlots ;
U8 mAllocatedSlots ;
U8 mDummySize ; //size of extra bytes reserved for mUsageBits.
public:
LLMemoryBlock* mPrev ;
LLMemoryBlock* mNext ;
LLMemoryBlock* mSelf ;
struct CompareAddress
{
bool operator()(const LLMemoryBlock* const& lhs, const LLMemoryBlock* const& rhs)
{
return (uintptr_t)lhs->getBuffer() < (uintptr_t)rhs->getBuffer();
}
};
};
class LL_COMMON_API LLMemoryChunk //is divided into memory blocks.
{
public:
LLMemoryChunk() ;
~LLMemoryChunk() ;
void init(char* buffer, U32 buffer_size, U32 min_slot_size, U32 max_slot_size, U32 min_block_size, U32 max_block_size) ;
void setBuffer(char* buffer, U32 buffer_size) ;
bool empty() ;
char* allocate(U32 size) ;
void freeMem(void* addr) ;
char* getBuffer() const {return mBuffer;}
U32 getBufferSize() const {return mBufferSize;}
U32 getAllocatedSize() const {return mAlloatedSize;}
bool containsAddress(const char* addr) const;
static U32 getMaxOverhead(U32 data_buffer_size, U32 min_slot_size,
U32 max_slot_size, U32 min_block_size, U32 max_block_size) ;
void dump() ;
private:
U32 getPageIndex(uintptr_t addr) ;
U32 getBlockLevel(U32 size) ;
U16 getPageLevel(U32 size) ;
LLMemoryBlock* addBlock(U32 blk_idx) ;
void popAvailBlockList(U32 blk_idx) ;
void addToFreeSpace(LLMemoryBlock* blk) ;
void removeFromFreeSpace(LLMemoryBlock* blk) ;
void removeBlock(LLMemoryBlock* blk) ;
void addToAvailBlockList(LLMemoryBlock* blk) ;
U32 calcBlockSize(U32 slot_size);
LLMemoryBlock* createNewBlock(LLMemoryBlock* blk, U32 buffer_size, U32 slot_size, U32 blk_idx) ;
private:
LLMemoryBlock** mAvailBlockList ;//256 by mMinSlotSize
LLMemoryBlock** mFreeSpaceList;
LLMemoryBlock* mBlocks ; //index of blocks by address.
char* mBuffer ;
U32 mBufferSize ;
char* mDataBuffer ;
char* mMetaBuffer ;
U32 mMinBlockSize ;
U32 mMinSlotSize ;
U32 mMaxSlotSize ;
U32 mAlloatedSize ;
U16 mBlockLevels;
U16 mPartitionLevels;
public:
//form a linked list
LLMemoryChunk* mNext ;
LLMemoryChunk* mPrev ;
} ;
private:
LLPrivateMemoryPool(S32 type, U32 max_pool_size) ;
~LLPrivateMemoryPool() ;
char *allocate(U32 size) ;
void freeMem(void* addr) ;
void dump() ;
U32 getTotalAllocatedSize() ;
U32 getTotalReservedSize() {return mReservedPoolSize;}
S32 getType() const {return mType; }
bool isEmpty() const {return !mNumOfChunks; }
private:
void lock() ;
void unlock() ;
S32 getChunkIndex(U32 size) ;
LLMemoryChunk* addChunk(S32 chunk_index) ;
bool checkSize(U32 asked_size) ;
void removeChunk(LLMemoryChunk* chunk) ;
U16 findHashKey(const char* addr);
void addToHashTable(LLMemoryChunk* chunk) ;
void removeFromHashTable(LLMemoryChunk* chunk) ;
void rehash() ;
bool fillHashTable(U16 start, U16 end, LLMemoryChunk* chunk) ;
LLMemoryChunk* findChunk(const char* addr) ;
void destroyPool() ;
public:
enum
{
SMALL_ALLOCATION = 0, //from 8 bytes to 2KB(exclusive), page size 2KB, max chunk size is 4MB.
MEDIUM_ALLOCATION, //from 2KB to 512KB(exclusive), page size 32KB, max chunk size 4MB
LARGE_ALLOCATION, //from 512KB to 4MB(inclusive), page size 64KB, max chunk size 16MB
SUPER_ALLOCATION //allocation larger than 4MB.
};
enum
{
STATIC = 0 , //static pool(each alllocation stays for a long time) without threading support
VOLATILE, //Volatile pool(each allocation stays for a very short time) without threading support
STATIC_THREADED, //static pool with threading support
VOLATILE_THREADED, //volatile pool with threading support
MAX_TYPES
}; //pool types
private:
LLMutex* mMutexp ;
U32 mMaxPoolSize;
U32 mReservedPoolSize ;
LLMemoryChunk* mChunkList[SUPER_ALLOCATION] ; //all memory chunks reserved by this pool, sorted by address
U16 mNumOfChunks ;
U16 mHashFactor ;
S32 mType ;
class LLChunkHashElement
{
public:
LLChunkHashElement() {mFirst = NULL ; mSecond = NULL ;}
bool add(LLMemoryChunk* chunk) ;
void remove(LLMemoryChunk* chunk) ;
LLMemoryChunk* findChunk(const char* addr) ;
bool empty() {return !mFirst && !mSecond; }
bool full() {return mFirst && mSecond; }
bool hasElement(LLMemoryChunk* chunk) {return mFirst == chunk || mSecond == chunk;}
private:
LLMemoryChunk* mFirst ;
LLMemoryChunk* mSecond ;
};
std::vector<LLChunkHashElement> mChunkHashList ;
};
class LL_COMMON_API LLPrivateMemoryPoolManager
{
private:
LLPrivateMemoryPoolManager(BOOL enabled, U32 max_pool_size) ;
~LLPrivateMemoryPoolManager() ;
public:
static LLPrivateMemoryPoolManager* getInstance() ;
static void initClass(BOOL enabled, U32 pool_size) ;
static void destroyClass() ;
LLPrivateMemoryPool* newPool(S32 type) ;
void deletePool(LLPrivateMemoryPool* pool) ;
private:
std::vector<LLPrivateMemoryPool*> mPoolList ;
U32 mMaxPrivatePoolSize;
static LLPrivateMemoryPoolManager* sInstance ;
static BOOL sPrivatePoolEnabled;
static std::vector<LLPrivateMemoryPool*> sDanglingPoolList ;
public:
//debug and statistics info.
void updateStatistics() ;
U32 mTotalReservedSize ;
U32 mTotalAllocatedSize ;
public:
#if __DEBUG_PRIVATE_MEM__
static char* allocate(LLPrivateMemoryPool* poolp, U32 size, const char* function, const int line) ;
typedef std::map<char*, std::string> mem_allocation_info_t ;
static mem_allocation_info_t sMemAllocationTracker;
#else
static char* allocate(LLPrivateMemoryPool* poolp, U32 size) ;
#endif
static void freeMem(LLPrivateMemoryPool* poolp, void* addr) ;
};
//-------------------------------------------------------------------------------------
#if __DEBUG_PRIVATE_MEM__
#define ALLOCATE_MEM(poolp, size) LLPrivateMemoryPoolManager::allocate((poolp), (size), __FUNCTION__, __LINE__)
#else
#define ALLOCATE_MEM(poolp, size) LLPrivateMemoryPoolManager::allocate((poolp), (size))
#endif
#define FREE_MEM(poolp, addr) LLPrivateMemoryPoolManager::freeMem((poolp), (addr))
//-------------------------------------------------------------------------------------
//
//the below singleton is used to test the private memory pool.
//
#if 0
class LL_COMMON_API LLPrivateMemoryPoolTester
{
private:
LLPrivateMemoryPoolTester() ;
~LLPrivateMemoryPoolTester() ;
public:
static LLPrivateMemoryPoolTester* getInstance() ;
static void destroy() ;
void run(S32 type) ;
private:
void correctnessTest() ;
void performanceTest() ;
void fragmentationtest() ;
void test(U32 min_size, U32 max_size, U32 stride, U32 times, bool random_deletion, bool output_statistics) ;
void testAndTime(U32 size, U32 times) ;
#if 0
public:
void* operator new(size_t size)
{
return (void*)sPool->allocate(size) ;
}
void operator delete(void* addr)
{
sPool->freeMem(addr) ;
}
void* operator new[](size_t size)
{
return (void*)sPool->allocate(size) ;
}
void operator delete[](void* addr)
{
sPool->freeMem(addr) ;
}
#endif
private:
static LLPrivateMemoryPoolTester* sInstance;
static LLPrivateMemoryPool* sPool ;
static LLPrivateMemoryPool* sThreadedPool ;
};
#if 0
//static
void* LLPrivateMemoryPoolTester::operator new(size_t size)
{
return (void*)sPool->allocate(size) ;
}
//static
void LLPrivateMemoryPoolTester::operator delete(void* addr)
{
sPool->free(addr) ;
}
//static
void* LLPrivateMemoryPoolTester::operator new[](size_t size)
{
return (void*)sPool->allocate(size) ;
}
//static
void LLPrivateMemoryPoolTester::operator delete[](void* addr)
{
sPool->free(addr) ;
}
#endif
#endif
// LLRefCount moved to llrefcount.h
// LLPointer moved to llpointer.h

View File

@ -588,7 +588,6 @@ std::string LLImage::sLastErrorMessage;
LLMutex* LLImage::sMutex = NULL;
bool LLImage::sUseNewByteRange = false;
S32 LLImage::sMinimalReverseByteRangePercent = 75;
LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ;
//static
void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
@ -596,8 +595,6 @@ void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_
sUseNewByteRange = use_new_byte_range;
sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
sMutex = new LLMutex(NULL);
LLImageBase::createPrivatePool() ;
}
//static
@ -605,8 +602,6 @@ void LLImage::cleanupClass()
{
delete sMutex;
sMutex = NULL;
LLImageBase::destroyPrivatePool() ;
}
//static
@ -644,25 +639,6 @@ LLImageBase::~LLImageBase()
deleteData(); // virtual
}
//static
void LLImageBase::createPrivatePool()
{
if(!sPrivatePoolp)
{
sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC_THREADED) ;
}
}
//static
void LLImageBase::destroyPrivatePool()
{
if(sPrivatePoolp)
{
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp) ;
sPrivatePoolp = NULL ;
}
}
// virtual
void LLImageBase::dump()
{
@ -696,7 +672,7 @@ void LLImageBase::sanityCheck()
// virtual
void LLImageBase::deleteData()
{
FREE_MEM(sPrivatePoolp, mData) ;
ll_aligned_free_16(mData);
disclaimMem(mDataSize);
mDataSize = 0;
mData = NULL;
@ -736,7 +712,7 @@ U8* LLImageBase::allocateData(S32 size)
if (!mBadBufferAllocation && (!mData || size != mDataSize))
{
deleteData(); // virtual
mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
mData = (U8*)ll_aligned_malloc_16(size);
if (!mData)
{
LL_WARNS() << "Failed to allocate image data size [" << size << "]" << LL_ENDL;
@ -763,7 +739,7 @@ U8* LLImageBase::allocateData(S32 size)
// virtual
U8* LLImageBase::reallocateData(S32 size)
{
U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
U8 *new_datap = (U8*)ll_aligned_malloc_16(size);
if (!new_datap)
{
LL_WARNS() << "Out of memory in LLImageBase::reallocateData" << LL_ENDL;
@ -773,7 +749,7 @@ U8* LLImageBase::reallocateData(S32 size)
{
S32 bytes = llmin(mDataSize, size);
memcpy(new_datap, mData, bytes); /* Flawfinder: ignore */
FREE_MEM(sPrivatePoolp, mData) ;
ll_aligned_free_16(mData) ;
}
mData = new_datap;
disclaimMem(mDataSize);
@ -1470,7 +1446,7 @@ bool LLImageRaw::scale( S32 new_width, S32 new_height, bool scale_image_data )
if (new_data_size > 0)
{
U8 *new_data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), new_data_size);
U8 *new_data = (U8*)ll_aligned_malloc_16(new_data_size);
if(NULL == new_data)
{
return false;
@ -2169,7 +2145,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size)
S32 newsize = cursize + size;
reallocateData(newsize);
memcpy(getData() + cursize, data, size);
FREE_MEM(LLImageBase::getPrivatePool(), data);
ll_aligned_free_16(data);
}
}
}

View File

@ -71,7 +71,6 @@ const S32 HTTP_PACKET_SIZE = 1496;
class LLImageFormatted;
class LLImageRaw;
class LLColor4U;
class LLPrivateMemoryPool;
typedef enum e_image_codec
{
@ -160,10 +159,6 @@ public:
static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent);
static EImageCodec getCodecFromExtension(const std::string& exten);
static void createPrivatePool() ;
static void destroyPrivatePool() ;
static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;}
//static LLTrace::MemStatHandle sMemStat;
@ -178,8 +173,6 @@ private:
bool mBadBufferAllocation ;
bool mAllowOverSize ;
static LLPrivateMemoryPool* sPrivatePoolp ;
};
// Raw representation of an image (used for textures, and other uncompressed formats

View File

@ -430,7 +430,7 @@ bool LLImageDXT::convertToDXR()
S32 nmips = calcNumMips(width,height);
S32 total_bytes = getDataSize();
U8* olddata = getData();
U8* newdata = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), total_bytes);
U8* newdata = (U8*)ll_aligned_malloc_16(total_bytes);
if (!newdata)
{
LL_ERRS() << "Out of memory in LLImageDXT::convertToDXR()" << LL_ENDL;

View File

@ -368,7 +368,7 @@ bool LLImageJ2C::loadAndValidate(const std::string &filename)
}
else
{
U8 *data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), file_size);
U8 *data = (U8*)ll_aligned_malloc_16(file_size);
if (!data)
{
infile.close();
@ -383,7 +383,7 @@ bool LLImageJ2C::loadAndValidate(const std::string &filename)
if (s != APR_SUCCESS || (S32)bytes_read != file_size)
{
FREE_MEM(LLImageBase::getPrivatePool(), data);
ll_aligned_free_16(data);
setLastError("Unable to read entire file");
res = false;
}

View File

@ -98,7 +98,6 @@ U32 LLVertexBuffer::sCurVAOName = 1;
U32 LLVertexBuffer::sAllocatedIndexBytes = 0;
U32 LLVertexBuffer::sIndexCount = 0;
LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL;
U32 LLVertexBuffer::sBindCount = 0;
U32 LLVertexBuffer::sSetCount = 0;
S32 LLVertexBuffer::sCount = 0;
@ -863,11 +862,6 @@ void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
{
sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject;
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping;
if (!sPrivatePoolp)
{
sPrivatePoolp = LLPrivateMemoryPoolManager::getInstance()->newPool(LLPrivateMemoryPool::STATIC);
}
}
//static
@ -910,12 +904,6 @@ void LLVertexBuffer::cleanupClass()
sStreamVBOPool.cleanup();
sDynamicVBOPool.cleanup();
sDynamicCopyVBOPool.cleanup();
if(sPrivatePoolp)
{
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp);
sPrivatePoolp = NULL;
}
}
//----------------------------------------------------------------------------
@ -1206,7 +1194,7 @@ bool LLVertexBuffer::createGLBuffer(U32 size)
{
static int gl_buffer_idx = 0;
mGLBuffer = ++gl_buffer_idx;
mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
mMappedData = (U8*)ll_aligned_malloc_16(size);
disclaimMem(mSize);
mSize = size;
claimMem(mSize);
@ -1248,7 +1236,7 @@ bool LLVertexBuffer::createGLIndices(U32 size)
}
else
{
mMappedIndexData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
mMappedIndexData = (U8*)ll_aligned_malloc_16(size);
static int gl_buffer_idx = 0;
mGLIndices = ++gl_buffer_idx;
mIndicesSize = size;
@ -1271,7 +1259,7 @@ void LLVertexBuffer::destroyGLBuffer()
}
else
{
FREE_MEM(sPrivatePoolp, (void*) mMappedData);
ll_aligned_free_16((void*)mMappedData);
mMappedData = NULL;
mEmpty = true;
}
@ -1291,7 +1279,7 @@ void LLVertexBuffer::destroyGLIndices()
}
else
{
FREE_MEM(sPrivatePoolp, (void*) mMappedIndexData);
ll_aligned_free_16((void*)mMappedIndexData);
mMappedIndexData = NULL;
mEmpty = true;
}

View File

@ -2369,7 +2369,7 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>DebugShowPrivateMem</key>
<key>DEPRECATED: DebugShowPrivateMem</key> <!-- deprecated (see MAINT-8091) -->
<map>
<key>Comment</key>
<string>Show Private Mem Info</string>
@ -6408,10 +6408,10 @@
<key>Value</key>
<real>600.0</real>
</map>
<key>MemoryPrivatePoolEnabled</key>
<key>MemoryPrivatePoolEnabled</key> <!-- deprecated (see MAINT-8091) -->
<map>
<key>Comment</key>
<string>Enable the private memory pool management</string>
<string>DEPRECATED: Enable the private memory pool management</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -6419,10 +6419,10 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>MemoryPrivatePoolSize</key>
<key>MemoryPrivatePoolSize</key> <!-- deprecated (see MAINT-8091) -->
<map>
<key>Comment</key>
<string>Size of the private memory pool in MB (min. value is 256)</string>
<string>DEPRECATED: Size of the private memory pool in MB (min. value is 256)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>

View File

@ -799,7 +799,6 @@ bool LLAppViewer::init()
initMaxHeapSize() ;
LLCoros::instance().setStackSize(gSavedSettings.getS32("CoroutineStackSize"));
LLPrivateMemoryPoolManager::initClass((BOOL)gSavedSettings.getBOOL("MemoryPrivatePoolEnabled"), (U32)gSavedSettings.getU32("MemoryPrivatePoolSize")*1024*1024) ;
// write Google Breakpad minidump files to a per-run dump directory to avoid multiple viewer issues.
std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, "");
mDumpPath = logdir;
@ -1363,10 +1362,6 @@ bool LLAppViewer::doFrame()
LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
LLSD newFrame;
//LLPrivateMemoryPoolTester::getInstance()->run(false) ;
//LLPrivateMemoryPoolTester::getInstance()->run(true) ;
//LLPrivateMemoryPoolTester::destroy() ;
LL_RECORD_BLOCK_TIME(FTM_FRAME);
LLTrace::BlockTimer::processTimes();
LLTrace::get_frame_recording().nextPeriod();
@ -2075,9 +2070,6 @@ bool LLAppViewer::cleanup()
LLMainLoopRepeater::instance().stop();
//release all private memory pools.
LLPrivateMemoryPoolManager::destroyClass() ;
ll_close_fail_log();
LLError::LLCallStacks::cleanup();

View File

@ -117,7 +117,7 @@ public:
~LLTextureCacheWorker()
{
llassert_always(!haveWork());
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
}
// override this interface
@ -237,7 +237,7 @@ bool LLTextureCacheLocalFileWorker::doRead()
// << " Bytes: " << mDataSize << " Offset: " << mOffset
// << " / " << mDataSize << LL_ENDL;
mDataSize = 0; // failed
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
}
return true;
@ -252,7 +252,7 @@ bool LLTextureCacheLocalFileWorker::doRead()
{
mDataSize = local_size;
}
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
mReadData = (U8*)ll_aligned_malloc_16(mDataSize);
S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
@ -262,7 +262,7 @@ bool LLTextureCacheLocalFileWorker::doRead()
// << " Bytes: " << mDataSize << " Offset: " << mOffset
// << " / " << mDataSize << LL_ENDL;
mDataSize = 0;
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
}
else
@ -386,7 +386,7 @@ bool LLTextureCacheRemoteWorker::doRead()
mDataSize = local_size;
}
// Allocate read buffer
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
mReadData = (U8*)ll_aligned_malloc_16(mDataSize);
if (mReadData)
{
@ -402,7 +402,7 @@ bool LLTextureCacheRemoteWorker::doRead()
<< " Bytes: " << mDataSize << " Offset: " << mOffset
<< " / " << mDataSize << LL_ENDL;
mDataSize = 0;
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
}
else
@ -451,7 +451,7 @@ bool LLTextureCacheRemoteWorker::doRead()
S32 size = TEXTURE_CACHE_ENTRY_SIZE - mOffset;
size = llmin(size, mDataSize);
// Allocate the read buffer
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), size);
mReadData = (U8*)ll_aligned_malloc_16(size);
if (mReadData)
{
S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName,
@ -461,7 +461,7 @@ bool LLTextureCacheRemoteWorker::doRead()
LL_WARNS() << "LLTextureCacheWorker: " << mID
<< " incorrect number of bytes read from header: " << bytes_read
<< " / " << size << LL_ENDL;
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
mDataSize = -1; // failed
done = true;
@ -500,7 +500,7 @@ bool LLTextureCacheRemoteWorker::doRead()
S32 data_offset, file_size, file_offset;
// Reserve the whole data buffer first
U8* data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
U8* data = (U8*)ll_aligned_malloc_16(mDataSize);
if (data)
{
// Set the data file pointers taking the read offset into account. 2 cases:
@ -514,7 +514,7 @@ bool LLTextureCacheRemoteWorker::doRead()
// Copy the raw data we've been holding from the header cache into the new sized buffer
llassert_always(mReadData);
memcpy(data, mReadData, data_offset);
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
}
else
@ -540,7 +540,7 @@ bool LLTextureCacheRemoteWorker::doRead()
LL_WARNS() << "LLTextureCacheWorker: " << mID
<< " incorrect number of bytes read from body: " << bytes_read
<< " / " << file_size << LL_ENDL;
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
mDataSize = -1; // failed
done = true;
@ -550,7 +550,7 @@ bool LLTextureCacheRemoteWorker::doRead()
{
LL_WARNS() << "LLTextureCacheWorker: " << mID
<< " failed to allocate memory for reading: " << mDataSize << LL_ENDL;
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
mDataSize = -1; // failed
done = true;
@ -673,11 +673,11 @@ bool LLTextureCacheRemoteWorker::doWrite()
{
// We need to write a full record in the header cache so, if the amount of data is smaller
// than a record, we need to transfer the data to a buffer padded with 0 and write that
U8* padBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), TEXTURE_CACHE_ENTRY_SIZE);
U8* padBuffer = (U8*)ll_aligned_malloc_16(TEXTURE_CACHE_ENTRY_SIZE);
memset(padBuffer, 0, TEXTURE_CACHE_ENTRY_SIZE); // Init with zeros
memcpy(padBuffer, mWriteData, mDataSize); // Copy the write buffer
bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, padBuffer, offset, size, mCache->getLocalAPRFilePool());
FREE_MEM(LLImageBase::getPrivatePool(), padBuffer);
ll_aligned_free_16(padBuffer);
}
else
{
@ -783,7 +783,7 @@ void LLTextureCacheWorker::finishWork(S32 param, bool completed)
}
else
{
FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
ll_aligned_free_16(mReadData);
mReadData = NULL;
}
}
@ -845,7 +845,7 @@ LLTextureCache::~LLTextureCache()
writeUpdatedEntries() ;
delete mFastCachep;
delete mFastCachePoolp;
FREE_MEM(LLImageBase::getPrivatePool(), mFastCachePadBuffer);
ll_aligned_free_16(mFastCachePadBuffer);
}
//////////////////////////////////////////////////////////////////////////////
@ -1983,10 +1983,10 @@ LLPointer<LLImageRaw> LLTextureCache::readFromFastCache(const LLUUID& id, S32& d
}
discardlevel = head[3];
data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), image_size);
data = (U8*)ll_aligned_malloc_16(image_size);
if(mFastCachep->read(data, image_size) != image_size)
{
FREE_MEM(LLImageBase::getPrivatePool(), data);
ll_aligned_free_16(data);
closeFastCache();
return NULL;
}
@ -2078,7 +2078,7 @@ void LLTextureCache::openFastCache(bool first_time)
{
if(!mFastCachePadBuffer)
{
mFastCachePadBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), TEXTURE_FAST_CACHE_ENTRY_SIZE);
mFastCachePadBuffer = (U8*)ll_aligned_malloc_16(TEXTURE_FAST_CACHE_ENTRY_SIZE);
}
mFastCachePoolp = new LLVolatileAPRPool();
if (LLAPRFile::isExist(mFastCacheFileName, mFastCachePoolp))

View File

@ -1761,7 +1761,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
mRequestedOffset += src_offset;
}
U8 * buffer = (U8 *)ALLOCATE_MEM(LLImageBase::getPrivatePool(), total_size);
U8 * buffer = (U8 *)ll_aligned_malloc_16(total_size);
if (!buffer)
{
// abort. If we have no space for packet, we have not enough space to decode image
@ -2266,7 +2266,7 @@ bool LLTextureFetchWorker::processSimulatorPackets()
if (buffer_size > cur_size)
{
/// We have new data
U8* buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), buffer_size);
U8* buffer = (U8*)ll_aligned_malloc_16(buffer_size);
S32 offset = 0;
if (cur_size > 0 && mFirstPacket > 0)
{
@ -5059,7 +5059,7 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
//LL_INFOS(LOG_TXT) << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << LL_ENDL;
if ((fetch.mCurlReceivedSize >= fetch.mRequestedSize) || !partial || (fetch.mRequestedSize == 600))
{
U8* d_buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size);
U8* d_buffer = (U8*)ll_aligned_malloc_16(data_size);
if (ba)
{
ba->read(0, d_buffer, data_size);

View File

@ -740,16 +740,6 @@ public:
ypos += y_inc;
}
if (gSavedSettings.getBOOL("DebugShowPrivateMem"))
{
LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ;
addText(xpos, ypos, llformat("Total Reserved(KB): %d", LLPrivateMemoryPoolManager::getInstance()->mTotalReservedSize / 1024));
ypos += y_inc;
addText(xpos, ypos, llformat("Total Allocated(KB): %d", LLPrivateMemoryPoolManager::getInstance()->mTotalAllocatedSize / 1024));
ypos += y_inc;
}
// only display these messages if we are actually rendering beacons at this moment
if (LLPipeline::getRenderBeacons() && LLFloaterReg::instanceVisible("beacons"))
{

View File

@ -2373,16 +2373,6 @@
function="ToggleControl"
parameter="DebugShowMemory" />
</menu_item_check>
<menu_item_check
label="Show Private Mem Info"
name="Show Private Mem Info">
<menu_item_check.on_check
function="CheckControl"
parameter="DebugShowPrivateMem" />
<menu_item_check.on_click
function="ToggleControl"
parameter="DebugShowPrivateMem" />
</menu_item_check>
<menu_item_separator/>