Tuesday, 29 July 2014
Écrit par
Grégory Soutadé

BSD systems are known to have the highest uptime, but our favorite GNU/Linux system can do the same if we want. At work my computer runs since 260 days without any reboot thanks to Ubuntu (LTS 10.04).

This is cool, nevertheless having software launched for a long time consume a lot of memory (I like to keep terminals and emacs open to save history), especially Firefox uses one to three giga bytes of memory (even in version 30.0). Software not used everyday goes to swap and come back when needed. This process can slow my computer for minutes (when I unlock my session).

The only solution is to kill these applications and restart them properly. I used to track memory eaters with "top" command, but it's hard to see in one time which software is using most of memory.

I wanted to do it for long time, and now it's out ! I wrote a PERL script called memstats that list processes by memory usage (and not by CPU usage like top).

It reads information from /proc/PID/stat and /proc/PID/status, so it's very Linux dependant (sorry BSDs...).

memstats output looks like "top" (because it's a good one).

soutade@cybelle> memstats
  PID    OWNER  VIRT   RES S       TIME         COMMAND
20098  soutade 3.10g 1.80g S   09:00:59         firefox
 1285     root  526m  259m S 6214:00:04            Xorg
 2555  soutade  862m  200m S 6214:00:10  gnome-terminal
 2113  soutade  827m  181m S 6214:00:20     gnome-panel
20081  soutade  866m  153m S   10:00:12     thunderbird
 2122  soutade 1.97g   98m S 6214:00:20        nautilus
 2192  soutade  591m   86m S 6214:00:13 indicator-apple
20104  soutade 1.07g   42m S   09:00:58          pidgin
26536  soutade  627m   40m S   06:00:22           gedit
 6517  soutade  529m   30m S 2816:00:40           emacs
 2845  soutade  442m   27m S   00:00:50           emacs
22935  soutade  449m   23m S  103:00:06           emacs
 2094  soutade  899m   23m S 6214:00:21        metacity
 2207  soutade  393m   11m S 6214:00:13 indicator-messa
 2762  soutade  114m   10m S   00:00:48          python
 9752  soutade  401m    8m S   96:00:18 gnome-screensav
 2070  soutade  766m    7m S 6214:00:22 gnome-settings-
 2914  soutade   94m    6m R   00:00:00        memstats
 2121  soutade  477m    6m S 6214:00:20 notification-da
 2489  soutade  414m    6m S 6214:00:20 update-notifier
23305  soutade  391m    5m S 5641:00:44 ubuntuone-syncd
 2280  soutade  418m    4m S 6214:00:10 gdu-notificatio
 2061  soutade   22m    4m S 6214:00:22     dbus-daemon
 1973     root  192m    4m S 6214:00:32         lightdm
 6886  soutade  581m    4m S 3797:00:46 gnome-keyring-d
 2134  soutade  539m    4m S 6214:00:19 gnome-fallback-
28423  soutade   85m    4m S   05:00:43            bash
 2389  soutade  335m    4m S 6214:00:00 zeitgeist-daemo
 6080  soutade  332m    4m S 3624:00:44      pulseaudio
 2382  soutade  400m    3m S 6214:00:00 zeitgeist-datah

memstats is licenced under GNU GPL v3 and available in my inDefero forge. Have fun !

Auteur :

e-mail* :

Le commentaire :

* Seulement pour être notifié d'une réponse à cet article
* Only for email notification