MCPcopy Create free account
hub / github.com/Compaile/ctrack / get_memory_usage

Function get_memory_usage

benchmark/ctrack_benchmark.cpp:57–68  ·  view source on GitHub ↗

Get current memory usage in bytes

Source from the content-addressed store, hash-verified

55
56// Get current memory usage in bytes
57size_t get_memory_usage()
58{
59#ifdef _WIN32
60 PROCESS_MEMORY_COUNTERS_EX pmc;
61 GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS *)&pmc, sizeof(pmc));
62 return pmc.WorkingSetSize;
63#else
64 struct rusage usage;
65 getrusage(RUSAGE_SELF, &usage);
66 return usage.ru_maxrss * 1024; // Convert KB to bytes on Linux
67#endif
68}
69
70// Precise busy wait function - waits for specified nanoseconds
71void busy_wait_ns(int64_t nanoseconds)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected