Process memory events with callstack.

This commit is contained in:
Bartosz Taudul 2018-06-19 18:52:45 +02:00
parent 59dc55002b
commit e51eef3dcd
2 changed files with 32 additions and 0 deletions

View File

@ -1447,6 +1447,15 @@ void Worker::Process( const QueueItem& ev )
case QueueType::MemFree:
ProcessMemFree( ev.memFree );
break;
case QueueType::MemAllocCallstack:
ProcessMemAllocCallstack( ev.memAlloc );
break;
case QueueType::MemFreeCallstack:
ProcessMemFreeCallstack( ev.memFree );
break;
case QueueType::CallstackMemory:
ProcessCallstackMemory( ev.callstackMemory );
break;
case QueueType::Terminate:
m_terminate = true;
break;
@ -1966,6 +1975,24 @@ void Worker::ProcessMemFree( const QueueMemFree& ev )
MemAllocChanged( time );
}
void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
{
m_lastMemActionCallstack = m_data.memory.data.size();
ProcessMemAlloc( ev );
}
void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev )
{
ProcessMemFree( ev );
m_lastMemActionCallstack = m_data.memory.frees.back();
}
void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev )
{
auto& mem = m_data.memory.data[m_lastMemActionCallstack];
mem.callstack = ev.ptr;
}
void Worker::MemAllocChanged( int64_t time )
{
const auto val = (double)m_data.memory.usage;

View File

@ -211,6 +211,9 @@ private:
tracy_force_inline void ProcessGpuResync( const QueueGpuResync& ev );
tracy_force_inline void ProcessMemAlloc( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFree( const QueueMemFree& ev );
tracy_force_inline void ProcessMemAllocCallstack( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFreeCallstack( const QueueMemFree& ev );
tracy_force_inline void ProcessCallstackMemory( const QueueCallstackMemory& ev );
tracy_force_inline void CheckSourceLocation( uint64_t ptr );
void NewSourceLocation( uint64_t ptr );
@ -296,6 +299,8 @@ private:
uint32_t m_pendingThreads;
uint32_t m_pendingSourceLocation;
uint64_t m_lastMemActionCallstack;
Slab<64*1024*1024> m_slab;
DataBlock m_data;