1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-06 07:03:52 +00:00

Initialize rpmalloc in Mem{Alloc,Free}Callstack().

rpmalloc may still be uninitialized here (i.e. if memory allocation/free
is performed before any other tracy operation that would initialize
thread_local data). Since memory allocations are using serialized queue
(which is not held in thread_local section) and obtaining callstack
involves memory allocation, we need to initialize rpmalloc manually.

This won't be a problem when support for zone callbacks becomes online,
because zones are stored in per-thread queues, which initialize
thread_local data before rpmalloc is needed in the Callstack() call.
This commit is contained in:
Bartosz Taudul 2018-06-21 17:02:40 +02:00
parent 3f7ab10323
commit 0c13fb818b

View File

@ -220,6 +220,7 @@ public:
{
const auto thread = GetThreadHandle();
rpmalloc_thread_initialize();
s_profiler.m_serialLock.lock();
SendMemAlloc( QueueType::MemAllocCallstack, thread, ptr, size );
SendCallstackMemory( depth );
@ -230,6 +231,7 @@ public:
{
const auto thread = GetThreadHandle();
rpmalloc_thread_initialize();
s_profiler.m_serialLock.lock();
SendMemFree( QueueType::MemFreeCallstack, thread, ptr );
SendCallstackMemory( depth );