mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 06:23:35 +02: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);
|
statex.dwLength = sizeof (statex);
|
||||||
GlobalMemoryStatusEx(&statex);
|
GlobalMemoryStatusEx(&statex);
|
||||||
return statex.ullTotalPhys / 1024 / 1024;
|
return statex.ullTotalPhys / 1024 / 1024;
|
||||||
#else
|
#elif defined Q_OS_MAC
|
||||||
return -1;
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue