Where does the memory go?

I've been running a bit low on memory recently, so I decided to find out where it's going. Obviously my browser is pretty memory-intensive, but I'm not sure there's much I can do about that (short of browsing less, all I can do is tune settings and/or change browsers). So I opened the system monitor and closed out the biggest memory users: firefox, soffice.bin, evolution*, and evince (I had a decent-sized PDF open). After closing those the memory use came down a bit: the largest memory users remaining were nautilus and gedit at 16 and 10 MB, respectively; everything else was taking a very small amount of RAM.

But the total memory use was still above 800 MiB: I calculated 810-812 MB not accounted for in the system monitor. The system monitor helpfully reported: "51% in use from programs, 11% for the cache" or something similar. Why is memory use so high? Vista only requires 512 MB; I have trouble believing that Ubuntu is greedier.

So I guess my questions come down to:

  1. What is using the remaining 800 MB?
  2. How can I reasonably conserve memory?
  3. How long before someone tells me to buy another 2GB? :smiley:
  • Why was evolution running in the first place? I don't use it and I've never opened it.

Most (some) UNIX systems will fill memory intentionally. This is done to prevent paging as much as possible. Unless your disk is thrashing, I see no real problem here. (You haven't told us how much memory you have though.)

Autostart at login? Check your session startup list.

I only posted because it had been thrashing. (Now that it's under the limit there's no problem, but I suspect that when I go over again it will do the same.) I identified this by

  1. A marked slowdown in all processes
  2. Hard drive sound
  3. The yellow virtual memory meter (I have the system monitor in my panel) spiked up, where it had previously (hours or days) been flat

I have 2 GB of memory.

See this post on Linux memory:

Instead of 'system monitor', whatever that is, try standard UNIX tools like ps. pastebinning the outputs of 'ps aux' would be informative.

By system monitor I mean the application gnome-system-monitor.

My problem is somewhat decreased by buying up to 4 GB of RAM, but as that's currently full (albeit no performance hit yet) I'll give the output requested:

user@computer:~$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   4104   364 ?        Ss   Jul04   0:00 /sbin/init
root         2  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S<   Jul04   0:01 [migration/0]
root         4  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   Jul04   0:00 [watchdog/0]
root         6  0.0  0.0      0     0 ?        S<   Jul04   0:01 [migration/1]
root         7  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksoftirqd/1]
root         8  0.0  0.0      0     0 ?        S<   Jul04   0:00 [watchdog/1]
root         9  0.0  0.0      0     0 ?        S<   Jul04   0:01 [migration/2]
root        10  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksoftirqd/2]
root        11  0.0  0.0      0     0 ?        S<   Jul04   0:00 [watchdog/2]
root        12  0.0  0.0      0     0 ?        S<   Jul04   0:01 [migration/3]
root        13  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksoftirqd/3]
root        14  0.0  0.0      0     0 ?        S<   Jul04   0:00 [watchdog/3]
root        15  0.0  0.0      0     0 ?        S<   Jul04   0:00 [events/0]
root        16  0.0  0.0      0     0 ?        S<   Jul04   0:00 [events/1]
root        17  0.0  0.0      0     0 ?        S<   Jul04   0:00 [events/2]
root        18  0.0  0.0      0     0 ?        S<   Jul04   0:00 [events/3]
root        19  0.0  0.0      0     0 ?        S<   Jul04   0:00 [khelper]
root        20  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kstop/0]
root        21  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kstop/1]
root        22  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kstop/2]
root        23  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kstop/3]
root        24  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kintegrityd/0]
root        25  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kintegrityd/1]
root        26  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kintegrityd/2]
root        27  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kintegrityd/3]
root        28  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kblockd/0]
root        29  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kblockd/1]
root        30  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kblockd/2]
root        31  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kblockd/3]
root        32  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kacpid]
root        33  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kacpi_notify]
root        34  0.0  0.0      0     0 ?        S<   Jul04   0:00 [cqueue]
root        35  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ata/0]
root        36  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ata/1]
root        37  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ata/2]
root        38  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ata/3]
root        39  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ata_aux]
root        40  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksuspend_usbd]
root        41  0.0  0.0      0     0 ?        S<   Jul04   0:00 [khubd]
root        42  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kseriod]
root        43  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmmcd]
root        44  0.0  0.0      0     0 ?        S<   Jul04   0:00 [btaddconn]
root        45  0.0  0.0      0     0 ?        S<   Jul04   0:00 [btdelconn]
root        48  0.0  0.0      0     0 ?        S<   Jul04   0:05 [kswapd0]
root        49  0.0  0.0      0     0 ?        S<   Jul04   0:00 [aio/0]
root        50  0.0  0.0      0     0 ?        S<   Jul04   0:00 [aio/1]
root        51  0.0  0.0      0     0 ?        S<   Jul04   0:00 [aio/2]
root        52  0.0  0.0      0     0 ?        S<   Jul04   0:00 [aio/3]
root        53  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ecryptfs-kthr]
root        56  0.0  0.0      0     0 ?        S<   Jul04   0:00 [scsi_eh_0]
root        57  0.0  0.0      0     0 ?        S<   Jul04   0:06 [scsi_eh_1]
root        58  0.0  0.0      0     0 ?        S<   Jul04   0:00 [scsi_eh_2]
root        59  0.0  0.0      0     0 ?        S<   Jul04   0:00 [scsi_eh_3]
root        60  0.0  0.0      0     0 ?        S<   Jul04   0:00 [scsi_eh_4]
root        61  0.0  0.0      0     0 ?        S<   Jul04   0:00 [scsi_eh_5]
root        62  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kstriped]
root        63  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmpathd/0]
root        64  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmpathd/1]
root        65  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmpathd/2]
root        66  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmpathd/3]
root        67  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kmpath_handle]
root        68  0.0  0.0      0     0 ?        S<   Jul04   0:00 [ksnapd]
root        69  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kondemand/0]
root        70  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kondemand/1]
root        71  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kondemand/2]
root        72  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kondemand/3]
root        73  0.0  0.0      0     0 ?        S<   Jul04   0:00 [krfcommd]
root       380  0.0  0.0      0     0 ?        S<   Jul04   0:00 [khpsbpkt]
root       672  0.0  0.0      0     0 ?        S<   Jul04   0:00 [knodemgrd_0]
root       799  0.0  0.0      0     0 ?        S<   Jul04   0:14 [kjournald]
root       933  0.0  0.0  16788   184 ?        S<s  Jul04   0:00 /sbin/udevd --d
root      1629  0.0  0.0      0     0 ?        S<   Jul04   0:00 [kpsmoused]
root      2272  0.0  0.0   3944   240 tty4     Ss+  Jul04   0:00 /sbin/getty 384
root      2273  0.0  0.0   3944   240 tty5     Ss+  Jul04   0:00 /sbin/getty 384
root      2276  0.0  0.0   3944   240 tty2     Ss+  Jul04   0:00 /sbin/getty 384
root      2278  0.0  0.0   3944   240 tty3     Ss+  Jul04   0:00 /sbin/getty 384
root      2280  0.0  0.0   3944   240 tty6     Ss+  Jul04   0:00 /sbin/getty 384
root      2354  0.0  0.0   4604   240 ?        Ss   Jul04   0:00 /usr/sbin/acpid
syslog    2393  0.0  0.0  12376   460 ?        Ss   Jul04   0:01 /sbin/syslogd -
root      2416  0.0  0.0   8204   236 ?        S    Jul04   0:00 /bin/dd bs 1 if
klog      2418  0.0  0.0   7144   348 ?        Ss   Jul04   0:00 /sbin/klogd -P
108       2441  0.0  0.0  21720  1084 ?        Ss   Jul04   0:12 /bin/dbus-daemo
111       2599  0.0  0.0  36560  1848 ?        Ss   Jul04   0:08 /usr/sbin/hald
root      2602  0.0  0.0 107436  2624 ?        Ssl  Jul04   0:05 /usr/sbin/conso
root      2666  0.0  0.0  15816   756 ?        S    Jul04   0:00 hald-runner
root      2695  0.0  0.0  28484   544 ?        S    Jul04   0:00 hald-addon-inpu
root      2747  0.0  0.0  28484   688 ?        S    Jul04   0:09 hald-addon-stor
root      2748  0.0  0.0  28492   448 ?        S    Jul04   0:00 /usr/lib/hal/ha
111       2749  0.0  0.0  32392   372 ?        S    Jul04   0:00 hald-addon-acpi
root      2767  0.0  0.0  28356   528 ?        Ss   Jul04   0:00 /usr/sbin/bluet
root      2806  0.0  0.0 123136   428 ?        Ss   Jul04   0:00 /usr/sbin/gdm
root      2809  0.0  0.0 144164   804 ?        S    Jul04   0:00 /usr/sbin/gdm
root      2814  4.9 40.6 1927648 1414296 tty7  Rs+  Jul04 141:43 /usr/X11R6/bin/
root      2833  0.0  0.0  36676   388 ?        Ss   Jul04   0:02 /usr/sbin/atiev
root      2865  0.0  0.0  70988  1284 ?        Ssl  Jul04   0:04 /usr/sbin/Netwo
avahi     2884  0.0  0.0  31896   588 ?        Ss   Jul04   0:01 avahi-daemon: r
avahi     2885  0.0  0.0  31764   124 ?        Ss   Jul04   0:00 avahi-daemon: c
root      2896  0.0  0.0  21100   332 ?        S    Jul04   0:00 /sbin/wpa_suppl
root      2899  0.0  0.0  69120  1232 ?        S    Jul04   0:01 /usr/sbin/nm-sy
root      2917  0.0  0.0  67960  1156 ?        Ss   Jul04   0:00 /usr/sbin/cupsd
root      2946  0.0  0.0  33296   504 ?        Ss   Jul04   0:00 /usr/bin/system
daemon    3019  0.0  0.0  16524   188 ?        Ss   Jul04   0:00 /usr/sbin/atd
root      3047  0.0  0.0  19972   356 ?        Ss   Jul04   0:00 /usr/sbin/cron
root      3144  0.0  0.0      0     0 ?        S<   Jul04   0:00 [firegl]
root      3145  0.0  0.0   3944   240 tty1     Ss+  Jul04   0:00 /sbin/getty 384
root      3164  0.0  0.0   6488   608 ?        S    Jul04   0:02 /sbin/dhclient
ntp       3280  0.0  0.0  29708   684 ?        Ss   Jul04   0:01 /usr/sbin/ntpd
charles   3454  0.0  0.0  84092   784 ?        S    Jul04   0:00 /usr/bin/gnome-
charles   3466  0.0  0.0 173984  2728 ?        Ssl  Jul04   0:03 x-session-manag
charles   3523  0.0  0.0  35940   128 ?        Ss   Jul04   0:00 /usr/bin/ssh-ag
charles   3526  0.0  0.0  23824   260 ?        S    Jul04   0:00 /usr/bin/dbus-l
charles   3527  0.0  0.0  21792  1172 ?        Ss   Jul04   0:01 //bin/dbus-daem
charles   3532  0.2  0.1 372328  3828 ?        Ssl  Jul04   5:50 /usr/bin/pulsea
charles   3533  0.0  0.0  68048   752 ?        S    Jul04   0:00 /usr/lib/pulsea
charles   3535  0.0  0.0  46076  3044 ?        S    Jul04   0:26 /usr/lib/libgco
charles   3546  0.0  0.0 165056  2024 ?        Ss   Jul04   0:00 /usr/bin/seahor
charles   3552  0.0  0.1 225740  4116 ?        Ssl  Jul04   0:30 /usr/lib/gnome-
charles   3556  0.0  0.0  41248  1396 ?        S    Jul04   0:00 /usr/lib/gvfs/g
charles   3564  0.0  0.0 144868  1056 ?        Ssl  Jul04   0:00 /usr/lib/gvfs//
charles   3570  0.0  0.0   4024   200 ?        S    Jul04   0:00 /bin/sh /usr/bi
charles   3637  0.3  0.1 234780  4916 ?        S    Jul04   9:16 /usr/bin/compiz
charles   3638  0.2  0.6 348612 23272 ?        S    Jul04   5:52 gnome-panel
charles   3640  0.0  0.7 529244 24704 ?        S    Jul04   0:43 nautilus
charles   3642  0.0  0.0 152348   820 ?        Ssl  Jul04   0:00 /usr/lib/bonobo
charles   3646  0.0  0.1 191976  3688 ?        S    Jul04   0:03 nm-applet --sm-
charles   3648  0.0  0.1 237344  4304 ?        S    Jul04   0:08 update-notifier
charles   3650  0.0  0.0 227248  3084 ?        Ss   Jul04   0:04 gnome-power-man
charles   3654  0.0  0.0 146936  2364 ?        S    Jul04   0:00 /usr/lib/notify
charles   3658  0.0  0.0  45424  1616 ?        S    Jul04   0:00 /usr/lib/gvfs/g
charles   3664  0.0  0.1 220100  3752 ?        S    Jul04   0:00 /usr/lib/gnome-
charles   3666  0.0  0.0  56136  1396 ?        S    Jul04   0:00 /usr/lib/gvfs/g
charles   3668  0.0  0.0  54484  1060 ?        S    Jul04   0:00 /usr/lib/gvfs/g
charles   3669  0.0  0.0   4024   184 ?        Ss   Jul04   0:00 /bin/sh -c /usr
charles   3670  0.0  0.0   4024   192 ?        S    Jul04   0:00 /bin/sh /usr/bi
charles   3672  0.1  0.2 195724  8048 ?        S    Jul04   2:54 /usr/bin/gtk-wi
charles   3675  0.4  0.1 217376  5552 ?        S    Jul04  13:26 /usr/lib/gnome-
charles   3681  0.0  0.1 280584  5532 ?        Sl   Jul04   0:01 /usr/lib/gnome-
charles   3687  0.0  0.0  40856   804 ?        S    Jul04   0:00 /usr/lib/gvfs/g
charles   3700 12.3 18.5 1626924 647508 ?      Rl   Jul04 357:07 /usr/lib/firefo
charles   3723  0.0  0.1 162048  3800 ?        Ss   Jul04   2:04 gnome-screensav
root      4014  0.0  0.0  72664  3360 ?        S    Jul04   0:00 /usr/bin/python
charles   5469  0.0  0.0 462340  2212 ?        Sl   Jul05   0:00 /usr/lib/evolut
charles   5473  0.0  0.0 414784  2596 ?        Sl   Jul05   0:00 /usr/lib/evolut
charles   5483  0.0  0.1 425940  3660 ?        Sl   Jul05   0:00 /usr/lib/evolut
charles   5929  0.2  0.5 200944 18096 ?        Sl   23:25   0:00 gnome-terminal
charles   5930  0.0  0.0  14412   784 ?        S    23:25   0:00 gnome-pty-helpe
charles   5931  0.0  0.1  20740  3548 pts/0    Ss+  23:25   0:00 bash
charles   6093  5.3  0.1  20840  3648 pts/1    Ss   23:32   0:00 bash
charles   6109  0.0  0.0  15172  1136 pts/1    R+   23:32   0:00 ps aux
charles   6414  0.1  2.8 378084 97976 ?        Sl   Jul05   4:46 evince file:///
charles  16229  0.2  4.0 918172 142004 ?       Sl   Jul05   5:46 /usr/lib/openof
root     32686  0.0  0.0      0     0 ?        S    Jul05   0:00 [pdflush]
root     32687  0.0  0.0      0     0 ?        S    Jul05   0:00 [pdflush]

That big honking thing leaking 40% of your RAM and counting looks like your X server. Note how its actual memory consumption is way higher than the amount still paged in(RSS), its allocating lots of memory, not using it, and having it paged out to make room for more! Try upgrading it.

(You can avoid the lines getting cut off by redirecting ps into a file or pipe, by the way.)

what is the output of the free command?

Corona, thank you. I haven't managed to update it yet, but it looks like you've identified the problem. It's definitely a slow memory leak -- when I first start the system it's taking a much smaller piece of RAM.

It's not too bad right now -- I only started the system 8 hours ago.

~$ free -m
             total       used       free     shared    buffers     cached
Mem:          3401       1913       1488          0         96        484
-/+ buffers/cache:       1331       2069
Swap:         5083          0       5083

The key line in your free output is the buffers/cache line.

Linux will make use of unused memory, and you want it to do this. I will cache things it thinks it may need in the future, almost like read-ahead on hard drives (very simple example and not totally accurate, but works for this).

As an application requires more memory, the kernel will flush some of the cache out to free up memory. So looking at that output, you have slightly over 2GB free.