mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Use rpmalloc to allocate tracy client memory.
This commit is contained in:
parent
e8968efea7
commit
c497966c7f
@ -20,6 +20,7 @@
|
||||
#include "../common/TracySocket.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "tracy_rpmalloc.hpp"
|
||||
#include "TracyAlloc.hpp"
|
||||
#include "TracyScoped.hpp"
|
||||
#include "TracyProfiler.hpp"
|
||||
|
||||
@ -39,13 +40,11 @@ namespace tracy
|
||||
struct RPMallocInit
|
||||
{
|
||||
RPMallocInit() { rpmalloc_initialize(); }
|
||||
~RPMallocInit() { rpmalloc_finalize(); }
|
||||
};
|
||||
|
||||
struct RPMallocThreadInit
|
||||
{
|
||||
RPMallocThreadInit() { rpmalloc_thread_initialize(); }
|
||||
~RPMallocThreadInit() { rpmalloc_thread_finalize(); }
|
||||
};
|
||||
|
||||
static const char* GetProcessName()
|
||||
@ -86,7 +85,7 @@ Profiler::Profiler()
|
||||
, m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() )
|
||||
, m_shutdown( false )
|
||||
, m_stream( LZ4_createStream() )
|
||||
, m_buffer( new char[TargetFrameSize*3] )
|
||||
, m_buffer( (char*)tracy_malloc( TargetFrameSize*3 ) )
|
||||
, m_bufferOffset( 0 )
|
||||
{
|
||||
assert( !s_instance );
|
||||
@ -106,7 +105,7 @@ Profiler::~Profiler()
|
||||
m_shutdown.store( true, std::memory_order_relaxed );
|
||||
m_thread.join();
|
||||
|
||||
delete[] m_buffer;
|
||||
tracy_free( m_buffer );
|
||||
LZ4_freeStream( m_stream );
|
||||
|
||||
assert( s_instance );
|
||||
@ -276,7 +275,7 @@ bool Profiler::HandleServerQuery()
|
||||
break;
|
||||
case ServerQueryCustomString:
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
delete[] (const char*)ptr;
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
case ServerQuerySourceLocation:
|
||||
SendSourceLocation( ptr );
|
||||
@ -286,7 +285,7 @@ bool Profiler::HandleServerQuery()
|
||||
break;
|
||||
case ServerQueryMessage:
|
||||
SendString( ptr, (const char*)ptr, QueueType::MessageData );
|
||||
delete[] (const char*)ptr;
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "concurrentqueue.h"
|
||||
#include "../common/tracy_lz4.hpp"
|
||||
#include "../common/TracyQueue.hpp"
|
||||
#include "TracyAlloc.hpp"
|
||||
|
||||
#if defined _MSC_VER || defined __CYGWIN__
|
||||
# include <intrin.h>
|
||||
@ -131,7 +132,7 @@ public:
|
||||
{
|
||||
uint32_t cpu;
|
||||
Magic magic;
|
||||
auto ptr = new char[size+1];
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& token = s_token.ptr;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "TracyAlloc.hpp"
|
||||
#include "TracyProfiler.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -43,7 +44,7 @@ public:
|
||||
tracy_force_inline void Text( const char* txt, size_t size )
|
||||
{
|
||||
Magic magic;
|
||||
auto ptr = new char[size+1];
|
||||
auto ptr = (char*)tracy_malloc( size+1 );
|
||||
memcpy( ptr, txt, size );
|
||||
ptr[size] = '\0';
|
||||
auto& token = s_token.ptr;
|
||||
|
Loading…
Reference in New Issue
Block a user