Track memory usage.

This commit is contained in:
Bartosz Taudul 2018-04-02 00:00:49 +02:00
parent e3509b6eee
commit 52f59c90bf
2 changed files with 3 additions and 0 deletions

View File

@ -228,6 +228,7 @@ struct MemData
flat_hash_map<uint64_t, MemEvent*, nohash<uint64_t>> active;
uint64_t high = std::numeric_limits<uint64_t>::min();
uint64_t low = std::numeric_limits<uint64_t>::max();
uint64_t usage = 0;
};
struct StringLocation

View File

@ -1646,6 +1646,7 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev )
m_data.memory.low = std::min( m_data.memory.low, mem->ptr );
m_data.memory.high = std::max( m_data.memory.high, mem->ptr + mem->size );
m_data.memory.usage += mem->size;
assert( m_data.memory.active.find( ev.ptr ) == m_data.memory.active.end() );
m_data.memory.active.emplace( ev.ptr, mem );
@ -1661,6 +1662,7 @@ void Worker::ProcessMemFree( const QueueMemFree& ev )
auto mem = it->second;
mem->timeFree = TscTime( ev.time );
mem->threadFree = CompressThread( ev.thread );
m_data.memory.usage -= mem->size;
m_data.memory.active.erase( it );
}