Ignore dangling memory frees in on-demand mode.

This commit is contained in:
Bartosz Taudul 2018-07-12 01:35:32 +02:00
parent e5064dec1e
commit c8b5b9447d
2 changed files with 28 additions and 13 deletions

View File

@ -2172,12 +2172,17 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev )
MemAllocChanged( time ); MemAllocChanged( time );
} }
void Worker::ProcessMemFree( const QueueMemFree& ev ) bool Worker::ProcessMemFree( const QueueMemFree& ev )
{ {
const auto time = TscTime( ev.time ); const auto time = TscTime( ev.time );
auto it = m_data.memory.active.find( ev.ptr ); auto it = m_data.memory.active.find( ev.ptr );
assert( it != m_data.memory.active.end() ); if( it == m_data.memory.active.end() )
{
assert( m_onDemand );
return false;
}
m_data.memory.frees.push_back( it->second ); m_data.memory.frees.push_back( it->second );
auto& mem = m_data.memory.data[it->second]; auto& mem = m_data.memory.data[it->second];
mem.timeFree = time; mem.timeFree = time;
@ -2186,6 +2191,7 @@ void Worker::ProcessMemFree( const QueueMemFree& ev )
m_data.memory.active.erase( it ); m_data.memory.active.erase( it );
MemAllocChanged( time ); MemAllocChanged( time );
return true;
} }
void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev ) void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
@ -2197,9 +2203,15 @@ void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev ) void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev )
{ {
ProcessMemFree( ev ); if( ProcessMemFree( ev ) )
m_lastMemActionCallstack = m_data.memory.frees.back(); {
m_lastMemActionWasAlloc = false; m_lastMemActionCallstack = m_data.memory.frees.back();
m_lastMemActionWasAlloc = false;
}
else
{
m_lastMemActionCallstack = std::numeric_limits<uint64_t>::max();
}
} }
void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev ) void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev )
@ -2207,14 +2219,17 @@ void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev )
auto it = m_pendingCallstacks.find( ev.ptr ); auto it = m_pendingCallstacks.find( ev.ptr );
assert( it != m_pendingCallstacks.end() ); assert( it != m_pendingCallstacks.end() );
auto& mem = m_data.memory.data[m_lastMemActionCallstack]; if( m_lastMemActionCallstack != std::numeric_limits<uint64_t>::max() )
if( m_lastMemActionWasAlloc )
{ {
mem.csAlloc = it->second; auto& mem = m_data.memory.data[m_lastMemActionCallstack];
} if( m_lastMemActionWasAlloc )
else {
{ mem.csAlloc = it->second;
mem.csFree = it->second; }
else
{
mem.csFree = it->second;
}
} }
m_pendingCallstacks.erase( it ); m_pendingCallstacks.erase( it );

View File

@ -243,7 +243,7 @@ private:
tracy_force_inline void ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev ); tracy_force_inline void ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev );
tracy_force_inline void ProcessGpuTime( const QueueGpuTime& ev ); tracy_force_inline void ProcessGpuTime( const QueueGpuTime& 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 bool ProcessMemFree( const QueueMemFree& ev );
tracy_force_inline void ProcessMemAllocCallstack( const QueueMemAlloc& ev ); tracy_force_inline void ProcessMemAllocCallstack( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFreeCallstack( const QueueMemFree& ev ); tracy_force_inline void ProcessMemFreeCallstack( const QueueMemFree& ev );
tracy_force_inline void ProcessCallstackMemory( const QueueCallstackMemory& ev ); tracy_force_inline void ProcessCallstackMemory( const QueueCallstackMemory& ev );