MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / getRamSize

Method getRamSize

src/os_linux.cpp:447–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447u64 OS::getRamSize() {
448 static u64 mem_total = 0;
449
450 if (mem_total == 0) {
451 FILE* file = fopen("/proc/meminfo", "r");
452 if (!file) return 0;
453
454 char line[1024];
455 while (fgets(line, sizeof(line), file)) {
456 if (strncmp(line, "MemTotal:", 9) == 0) {
457 mem_total = strtoull(line + 9, NULL, 10) * 1024;
458 break;
459 }
460 }
461
462 fclose(file);
463 }
464
465 return mem_total;
466}
467
468u64 OS::getSystemBootTime() {
469 static u64 system_boot_time = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected