Showing the changes to interface/src/scripting/PlatformInfoScriptingInterface.cpp (1 of 1 file). Show all
Unified · Split
| @@ -78,8 +78,19 @@ int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() { · 77 unmodified lines | ||
| 78 | 78 | statex.dwLength = sizeof (statex); |
| 79 | 79 | GlobalMemoryStatusEx(&statex); |
| 80 | 80 | return statex.ullTotalPhys / 1024 / 1024; |
| 81 | −#else | |
| 82 | − return -1; | |
| 81 | +#elif defined Q_OS_MAC | |
| 82 | + FILE* stream = popen("sysctl -a | grep hw.memsize", "r"); | |
| 83 | + | |
| 84 | + std::ostringstream hostStream; | |
| 85 | + while (!feof(stream) && !ferror(stream)) { | |
| 86 | + char buf[128]; | |
| 87 | + int bytesRead = fread(buf, 1, 128, stream); | |
| 88 | + hostStream.write(buf, bytesRead); | |
| 89 | + } | |
| 90 | + | |
| 91 | + QString result = QString::fromStdString(hostStream.str()); | |
| 92 | + QStringList parts = result.split(' '); | |
| 93 | + return (int)(parts[1].toDouble() / 1024 / 1024); | |
| 83 | 94 | #endif |
| 84 | 95 | } |
| 85 | 96 | |