mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Can get total memory on Mac
This commit is contained in:
parent
9c00bdcddb
commit
a3dde612d1
1 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue