Getting memory information with Qt

  • 2 Answer(s)

    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)) {
            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");
    QString memory = p.readAllStandardOutput();
    system_info.append(QString("; RAM: %1 MB").arg(memory.toLong() / 1024));

    Mac sysctl

    QProcess p;
    p.start("sysctl", QStringList() << "kern.version" << "hw.physmem");
    QString system_info = p.readAllStandardOutput();
    Answered on December 27, 2018.
    Add Comment

    The  POSIX OSes Linux, Solaris, perhaps latest MacOS:

    • getrusage(…) secially look at ru_maxrss.
    • getrlimit(…) but I did not find any usefull info into.
    • sysinfo(…) : totalram, freeram, sharedram, totalswap,…

    The cache  on POSIX computers are not accesible on Windows.

    Answered on December 27, 2018.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.