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