diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 33b349e032..bcf4e79d76 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -78,8 +78,19 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { statex.dwLength = sizeof (statex); GlobalMemoryStatusEx(&statex); return statex.ullTotalPhys / 1024 / 1024; -#else - return -1; +#elif defined Q_OS_MAC + FILE* stream = popen("sysctl -a | grep hw.memsize", "r"); + + std::ostringstream hostStream; + while (!feof(stream) && !ferror(stream)) { + char buf[128]; + int bytesRead = fread(buf, 1, 128, stream); + hostStream.write(buf, bytesRead); + } + + QString result = QString::fromStdString(hostStream.str()); + QStringList parts = result.split(' '); + return (int)(parts[1].toDouble() / 1024 / 1024); #endif }