mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Get available physical memory size in viewer.
This commit is contained in:
parent
0e50c9f6ea
commit
2bf00b5eab
@ -46,6 +46,15 @@
|
||||
# include "../nfd/nfd.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#elif defined __linux__
|
||||
# include <sys/sysinfo.h>
|
||||
#elif defined __APPLE__ || defined BSD
|
||||
# include <sys/types.h>
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "IconsFontAwesome5.h"
|
||||
|
||||
#ifndef M_PI_2
|
||||
@ -132,6 +141,7 @@ View::View( void(*cbMainThread)(std::function<void()>), const char* addr, uint16
|
||||
assert( s_instance == nullptr );
|
||||
s_instance = this;
|
||||
|
||||
InitMemory();
|
||||
InitTextEditor( fixedWidth );
|
||||
}
|
||||
|
||||
@ -155,6 +165,7 @@ View::View( void(*cbMainThread)(std::function<void()>), FileRead& f, ImFont* fix
|
||||
m_notificationTime = 4;
|
||||
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
|
||||
|
||||
InitMemory();
|
||||
InitTextEditor( fixedWidth );
|
||||
SetViewToLastFrames();
|
||||
m_userData.StateShouldBePreserved();
|
||||
@ -184,6 +195,32 @@ View::~View()
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
void View::InitMemory()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof( statex );
|
||||
GlobalMemoryStatusEx( &statex );
|
||||
m_totalMemory = statex.ullTotalPhys;
|
||||
#elif defined __linux__
|
||||
struct sysinfo sysInfo;
|
||||
sysinfo( &sysInfo );
|
||||
m_totalMemory = sysInfo.totalram;
|
||||
#elif defined __APPLE__
|
||||
size_t memSize;
|
||||
size_t sz = sizeof( memSize );
|
||||
sysctlbyname( "hw.memsize", &memSize, &sz, nullptr, 0 );
|
||||
m_totalMemory = memSize;
|
||||
#elif defined BSD
|
||||
size_t memSize;
|
||||
size_t sz = sizeof( memSize );
|
||||
sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 );
|
||||
m_totalMemory = memSize;
|
||||
#else
|
||||
m_totalMemory = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void View::InitTextEditor( ImFont* font )
|
||||
{
|
||||
m_sourceView = std::make_unique<SourceView>( font, m_gwcb );
|
||||
|
@ -138,6 +138,7 @@ private:
|
||||
LastRange
|
||||
};
|
||||
|
||||
void InitMemory();
|
||||
void InitTextEditor( ImFont* font );
|
||||
|
||||
const char* ShortenNamespace( const char* name ) const;
|
||||
@ -328,6 +329,7 @@ private:
|
||||
ViewMode m_viewMode;
|
||||
bool m_viewModeHeuristicTry = false;
|
||||
DecayValue<bool> m_forceConnectionPopup = false;
|
||||
uint64_t m_totalMemory;
|
||||
|
||||
ViewData m_vd;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user