mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 06:35:08 -04:00
attempt to fix the crash at exit, due to some threads asking for memory while the memory management structure is already gone
This commit is contained in:
parent
22fd4e4092
commit
e56ba457fe
2 changed files with 20 additions and 5 deletions
|
@ -158,6 +158,13 @@ void FixedAllocator::deallocate(void *p)
|
||||||
_chunks.pop_back();
|
_chunks.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint32_t FixedAllocator::currentSize() const
|
||||||
|
{
|
||||||
|
uint32_t res = 0 ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<_chunks.size();++i)
|
||||||
|
res += (_numBlocks - _chunks[i]->_blocksAvailable) * _blockSize ;
|
||||||
|
}
|
||||||
void FixedAllocator::printStatistics() const
|
void FixedAllocator::printStatistics() const
|
||||||
{
|
{
|
||||||
std::cerr << " numBLocks=" << (int)_numBlocks << std::endl;
|
std::cerr << " numBLocks=" << (int)_numBlocks << std::endl;
|
||||||
|
@ -181,10 +188,17 @@ SmallObjectAllocator::~SmallObjectAllocator()
|
||||||
{
|
{
|
||||||
RsStackMutex m(SmallObject::_mtx) ;
|
RsStackMutex m(SmallObject::_mtx) ;
|
||||||
|
|
||||||
for(std::map<int,FixedAllocator*>::const_iterator it(_pool.begin());it!=_pool.end();++it)
|
//std::cerr << __PRETTY_FUNCTION__ << " not deleting. Leaving it to the system." << std::endl;
|
||||||
delete it->second ;
|
|
||||||
|
|
||||||
_active = false ;
|
_active = false ;
|
||||||
|
|
||||||
|
uint32_t still_allocated = 0 ;
|
||||||
|
|
||||||
|
for(std::map<int,FixedAllocator*>::const_iterator it(_pool.begin());it!=_pool.end();++it)
|
||||||
|
still_allocated += it->second->currentSize() ;
|
||||||
|
//delete it->second ;
|
||||||
|
|
||||||
|
std::cerr << "Memory still in use at end of program: " << still_allocated << " bytes." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SmallObjectAllocator::allocate(size_t bytes)
|
void *SmallObjectAllocator::allocate(size_t bytes)
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace RsMemoryManagement
|
||||||
}
|
}
|
||||||
|
|
||||||
void printStatistics() const ;
|
void printStatistics() const ;
|
||||||
|
uint32_t currentSize() const;
|
||||||
private:
|
private:
|
||||||
size_t _blockSize ;
|
size_t _blockSize ;
|
||||||
unsigned char _numBlocks ;
|
unsigned char _numBlocks ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue