2

I would like to measure the RAM usage of several desktop environments (including Cinnamon, GNOME, KDE, LXDE, LXQt, MATE and Xfce) running on my Sabayon machine. I would prefer a command-line way of checking RAM usage, if possible. I have tried using this ps_mem.py script (by running python ps_mem.py -p Cinnamon for Cinnamon, for example) but unfortunately it requires PIDs for programs and will not simply accept the name of the DE and I'm not sure which programs belong to my DE and which do not.

  • 2
    This is a rather difficult problem, because a desktop environment does not just use a certain amount of memory and that's it. Many programs allocate memory as needed, which basically means it will consume more memory the more/longer you work with your computer. Then it depends on the kind of work you do how much memory the programs require and of course on the specific config of your DEs.Why do you want to measure RAM usage? – Bananguin Sep 28 '15 at 19:26
  • To compare it across the desktop environments. So if there is a way to make it a nice level playing field so that I can make a fair comparison in RAM usage across the DEs I would certainly like it. – BH2017 Sep 28 '15 at 19:32
1

You can put together a command that parses free to tell you how much free memory you have:

free -h | awk {'print $3'} | head -3 | tail -1
1.8G

Run the bash script every half second to keep a record of your memory usage:

while true; do free | awk {'print $3'} | head -3 | tail -1 >> free.dat; sleep 0.5; done

For each environment you want to test, put that script in the list of automatically run programs (e.g., for Fluxbox it goes in ~/.fluxbox/startup). You can readily view your plots by running gnuplot and calling

gnuplot> plot 'free.fluxbox.dat' using 1 with impulses

enter image description here

Now, the hard part is your apples to apples comparison. If you want to see how memory usage looks after opening lots of programs, you can put this script in yet another script, followed by subsequent calls to libreoffice, firefox and gnome-system-monitor, or whatever list you like. Alternatively, you could just open them manually, but that really doesn't seem like a tenable approach to honestly comparing environments.

  • I plan on writing a blog post on this, and hence I would like a nice singular number to present for each DE. Like an average, or RAM usage during boot, or etc. Like your answer seems wonderful if all my readers were mathematicians or statisticians but not humble Sabayon users. With that being said this answer is definitely a good effort, I realize I didn't give much specifics of what I wanted exactly. – BH2017 Sep 28 '15 at 20:36
  • @BrentonHorne Well that's disappointing. Anyway, you can get an average from the dat file by calling awk '{s+=$1}END{print "avg:",s/NR}' RS=" " free.dat after you're done running the script. – user1717828 Sep 28 '15 at 21:30
  • Btw what's the autostart script for the enlightenment DE? I have Googled for it but I can't seem to find it. – BH2017 Sep 28 '15 at 21:50
  • I've also noticed that free.dat for me only contains lines of the number 168. Which for me is odd as I'd expect my free RAM to vary with time. – BH2017 Sep 28 '15 at 22:49
  • @BrentonHorne If you're running free with the -h flag (for human readable), it will output something in the MB or GB range since that's the easiest for humans to read. Try running without that flag to get the result in bytes. – user1717828 Sep 29 '15 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.