This is a small utility that prints memory (RAM) information to stdout.
It is intended to be used with status bars like Lemonbar and/or their
wrappers, like succade.
The tool gets information about the amount of total and available memory from
/proc/meminfo, then calculates the current memory usage from it. For this, it
looks at the values MemTotal, MemAvailable and MemFree. Based on these,
the tool will also calculate used and bound memory (see below for details).
The difference between available and free memory is that the former gives a more intuitive value. That is because available memory takes into account memory that is currently used by Linux, but can and will be freed as soon as any application needs it. In summary:
- Availble: memory theoretically available (via freeing)
- Free: memory practically and immediately available (without freeing)
- Used: total minus available memory (memory in use by applications)
- Bound: total minus free memory (memory in use by applications and Linux)
None (other than standard libraries and gcc).
- Run the included
buildscript
mem-proc [OPTIONS...]
-buse binary instead of decimal units (MiB vs MB, etc)-f FORMATformat string for the output (see below); default is%u-F FILEfile to query for memory info; default is/proc/meminfo-g GRANULARITYvalue granularity (kfor KB,mfor MB, etc)-hprint usage information, then exit-i INTERVALseconds between reading memory usage; default is1-kkeep printing even if the ouput hasn't changed (only in combination with-m)-mkeep running and print when there is a change in output-p PRECISIONnumber of decimal digits to include in the output; default is0-sprint a space between the value and unit-uadd the unit (%orGiBrespectively) to the output-Vprint version information and exit
%Tand%t: total memory, absolute and percent%Aand%a: available memory, absolute and percent%Fand%f: free memory, absolute and percent%Uand%u: used memory, absolute and percent%Band%b: bound memory, absolute and percent
Print the used memory in percent, with two decimal digits and space-separated unit:
$ ./bin/mem-proc -us -p 2
23.11 %
Print the available memory in MiB, with space-separated unit but no decimal digits:
$ ./bin/mem-proc -us -f "%A" -g m -b
13280 MiB
Continuously print the used memory, in GB, with three decimals and space-separated unit:
$ ./bin/mem-proc -mus -f "%U" -p 3
3.988 GB
3.803 GB
3.976 GB
4.002 GB