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: case QueueType::MemFree:
ProcessMemFree( ev.memFree ); ProcessMemFree( ev.memFree );
break; 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: case QueueType::Terminate:
m_terminate = true; m_terminate = true;
break; break;
@ -1966,6 +1975,24 @@ void Worker::ProcessMemFree( const QueueMemFree& ev )
MemAllocChanged( time ); 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 ) void Worker::MemAllocChanged( int64_t time )
{ {
const auto val = (double)m_data.memory.usage; 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 ProcessGpuResync( const QueueGpuResync& ev );
tracy_force_inline void ProcessMemAlloc( const QueueMemAlloc& ev ); tracy_force_inline void ProcessMemAlloc( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFree( const QueueMemFree& 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 ); tracy_force_inline void CheckSourceLocation( uint64_t ptr );
void NewSourceLocation( uint64_t ptr ); void NewSourceLocation( uint64_t ptr );
@ -296,6 +299,8 @@ private:
uint32_t m_pendingThreads; uint32_t m_pendingThreads;
uint32_t m_pendingSourceLocation; uint32_t m_pendingSourceLocation;
uint64_t m_lastMemActionCallstack;
Slab<64*1024*1024> m_slab; Slab<64*1024*1024> m_slab;
DataBlock m_data; DataBlock m_data;