1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Memory allocations tracker.

This commit is contained in:
Bartosz Taudul
2018-03-31 21:56:05 +02:00
parent 7a35e8facc
commit 991fc6bd95
4 changed files with 55 additions and 0 deletions
+27
View File
@@ -186,6 +186,33 @@ public:
tail.store( magic + 1, std::memory_order_release );
}
static tracy_force_inline void MemAlloc( const void* ptr, size_t size )
{
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::MemAlloc );
MemWrite( &item->memAlloc.time, GetTime() );
MemWrite( &item->memAlloc.thread, GetThreadHandle() );
MemWrite( &item->memAlloc.ptr, (uint64_t)ptr );
memcpy( &item->memAlloc.size, &size, 6 );
tail.store( magic + 1, std::memory_order_release );
}
static tracy_force_inline void MemFree( const void* ptr )
{
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::MemFree );
MemWrite( &item->memFree.time, GetTime() );
MemWrite( &item->memFree.thread, GetThreadHandle() );
MemWrite( &item->memFree.ptr, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release );
}
static bool ShouldExit();
private: