12 #include <mrpt/config.h> 20 #include <mach/mach_init.h> 21 #include <mach/task.h> 61 typedef BOOL(WINAPI* TGetProcessMemoryInfo)(
73 m_dll = LoadLibraryA(
"PSAPI.DLL");
76 m_ptr = (TGetProcessMemoryInfo)GetProcAddress(
77 m_dll,
"GetProcessMemoryInfo");
98 return (*m_ptr)(Process, ppsmemCounters, cb);
117 unsigned long MEM = 0;
124 pmc.
cb =
sizeof(pmc);
127 GetCurrentProcess(), &pmc,
sizeof(pmc)))
134 FILE* f =
::fopen(
"/proc/self/statm",
"r");
137 unsigned long mem_pages = 0;
139 if (!::fscanf(f,
"%*d %*d %*d %*d %*d %lu %*d", &mem_pages))
147 static const long pagesize = ::sysconf(_SC_PAGE_SIZE);
148 MEM =
static_cast<decltype(
MEM)
>(pagesize) * mem_pages;
153 mach_task_basic_info info;
154 mach_msg_type_number_t
count = MACH_TASK_BASIC_INFO_COUNT;
156 mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info,
159 MEM = info.virtual_size;
GLuint GLuint GLsizei count
struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
int void fclose(FILE *f)
An OS-independent version of fclose.
SIZE_T PeakWorkingSetSize
BOOL WINAPI GetProcessMemoryInfo(HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb)
This is an auxiliary class for mrpt::system::getMemoryUsage() under Windows.
SIZE_T QuotaNonPagedPoolUsage
SIZE_T QuotaPeakNonPagedPoolUsage
SIZE_T QuotaPagedPoolUsage
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned long getMemoryUsage()
Returns the memory occupied by this process, in bytes.
struct _PROCESS_MEMORY_COUNTERS * PPROCESS_MEMORY_COUNTERS
SIZE_T QuotaPeakPagedPoolUsage
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
TGetProcessMemoryInfo m_ptr