How can I obtain this information:
- Total Memory
- Free Memory
- Memory used by current running application ?
I think Qt should have memory options, that would be platform-independent, but
I can’t find it. So what can I do when I want to make a platform-independent application that shows memory state?
Unfortunately, there is nothing built into Qt for this. You must do this per-platform.
Here are some samples to get you started. I had to implement this in one of my apps just last week. The code below is still very much in development; there may be errors or leaks, but it might at least point you in the correct direction. I was only interested in total physical RAM, but the other values are available in the same way. (Except perhaps memory in use by the current application … not sure about that one.)
Windows (GlobalMemoryStatusEx)
Linux (/proc/meminfo)
Mac (sysctl)