MCPcopy Create free account
hub / github.com/DigitalInBlue/Celero / GetRAMVirtualUsedByCurrentProcess

Method GetRAMVirtualUsedByCurrentProcess

src/Memory.cpp:365–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365int64_t celero::GetRAMVirtualUsedByCurrentProcess()
366{
367#ifdef _WIN32
368 PROCESS_MEMORY_COUNTERS_EX pmc;
369 GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc), sizeof(pmc));
370 return pmc.PrivateUsage;
371#elif defined(__APPLE__)
372 return -1;
373#else
374 // Verified Correct.
375 constexpr int BufferSize{128};
376 int64_t result = 0;
377 FILE* file = fopen("/proc/self/status", "r");
378
379 if(file == nullptr)
380 {
381 return -1;
382 }
383
384 char line[BufferSize];
385
386 while(fgets(line, BufferSize, file) != NULL)
387 {
388 if(strncmp(line, "VmSize:", 7) == 0)
389 {
390 result = celero::impl::ParseLine(line) * Kilobytes2Bytes;
391 break;
392 }
393 }
394
395 fclose(file);
396 return result;
397#endif
398}
399
400celero::RAMReport celero::GetRAMReport()
401{

Callers

nothing calls this directly

Calls 1

ParseLineFunction · 0.85

Tested by

no test coverage detected