Skip to content
Snippets Groups Projects
Commit a979705a authored by Sven Marcus's avatar Sven Marcus
Browse files

MemoryUtil can determine total physical memory on macOS

parent eff8595d
No related branches found
No related tags found
No related merge requests found
......@@ -42,8 +42,13 @@ namespace Utilities
long long totalPhysMem = memInfo.totalram;
//Multiply in next statement to avoid int overflow on right hand side...
totalPhysMem *= memInfo.mem_unit;
#elif defined(MEMORYUTIL_APPLE)
long long totalPhysMem = 0;
#elif defined(MEMORYUTIL_APPLE)
int mib [] = { CTL_HW, HW_MEMSIZE };
int64_t totalPhysMem;
size_t length = sizeof(totalPhysMem);
if(sysctl(mib, 2, &totalPhysMem, &length, nullptr, 0) == -1)
return 0;
#else
#error "MemoryUtil::getTotalPhysMem - UnknownMachine"
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment