Getting memory information with Qt
Memory information with Qt:
They developed by using the given code and make the error point in the write control. The values are possible in the present the perhaps memory is used at the present application
Windows GlobalMemoryStatusEx
MEMORYSTATUSEX memory_status; ZeroMemory(&memory_status, sizeof(MEMORYSTATUSEX)); memory_status.dwLength = sizeof(MEMORYSTATUSEX); if (GlobalMemoryStatusEx(&memory_status)) { system_info.append( QString("RAM: %1 MB") .arg(memory_status.ullTotalPhys / (1024 * 1024))); } else { system_info.append("Unknown RAM"); }
Linux proc/meminfo
QProcess p; p.start("awk", QStringList() << "/MemTotal/ { print $2 }" << "/proc/meminfo"); p.waitForFinished(); QString memory = p.readAllStandardOutput(); system_info.append(QString("; RAM: %1 MB").arg(memory.toLong() / 1024)); p.close();
Mac sysctl
QProcess p; p.start("sysctl", QStringList() << "kern.version" << "hw.physmem"); p.waitForFinished(); QString system_info = p.readAllStandardOutput(); p.close();
The POSIX OSes Linux, Solaris, perhaps latest MacOS:
- getrusage(…) secially look at ru_maxrss.
- getrlimit(…) but I did not find any usefull info into.
- sysconf(…) : _SC_PAGESIZE, _SC_PHYS_PAGES, _SC_AVPHYS_PAGES
- sysinfo(…) : totalram, freeram, sharedram, totalswap,…
The cache on POSIX computers are not accesible on Windows.