5

free -m does not seems to include memory used by RAM disks (tmpfs filesystems). Maybe because it's something in the kernel space?

How do I get the real memory usage (or it's opposite, free memory) including the allocated space of filesystems that reside in RAM like tmpfs?

I currently check for the memory usage by running df -h and adding the "In use" numbers to the -/+ buffers/cache number. Is there a command available that gives me the real memory usage?

3
  • Could you share some more info, such as the output of free -m; cat /proc/meminfo; swapon -s; mount (while you have that tmpfs you mention) Jul 1, 2012 at 6:28
  • Oh, and df -h -- Darn, I just noticed that this question is old, sorry. Jul 1, 2012 at 6:35
  • @medigeek You can reproduce it with free -m;cat /proc/meminfo>1; dd if=/dev/zero of=/tmp/big bs=1M count=400; free -m;cat /proc/meminfo>2;diff -u 1 2 (assuming that /tmp is mounted as tmpfs and has at least 400MiB memory available)
    – Lekensteyn
    Jul 1, 2012 at 9:28

2 Answers 2

3

you can install htop via the terminal

sudo apt-get install htop

then run htop in the terminal

disclaimer I guess this does not work on Lucid correctly

enter image description here

8
  • This memory information is the same as free -m. I prefer a solution that gives me immediately details, without refreshing like free. The calculation could be done with awk, but there should be a single command available, shouldn't it?
    – Lekensteyn
    May 7, 2011 at 19:44
  • htop gives you non-static ram usage... in others words, it shows you exactly what kind of ram you are using at any given time, as long as you have it running.
    – TheXed
    May 7, 2011 at 20:18
  • @TheX: I think I've not been clear then, this number does not include memory usage by ram disks. Try it yourself, create a 200MB file using dd if=/dev/zero of=/dev/shm/bigfile bs=1M count=200. You'll notice that the memory usage reported by htop and free does not change.
    – Lekensteyn
    May 7, 2011 at 20:22
  • mine changed... I guess my next question is what exactly do you mean by disk ram?
    – TheXed
    May 7, 2011 at 20:25
  • @TheX: weird, it seems to work on Natty, but not on Lucid. I can't find anything in the changelogs (natty and lucid). Must be a kernel change?
    – Lekensteyn
    May 7, 2011 at 20:29
2

According to a redhat guide:

When you interpret the values reported by memory.stat, note how the various statistics inter-relate:

active_anon + inactive_anon = anonymous memory + file cache for tmpfs + swap cache

Therefore, active_anon + inactive_anon ≠ rss, because rss does not include tmpfs.

active_file + inactive_file = cache - size of tmpfs

According to that, there must be some co-relation to the command output of cat /proc/meminfo

Active:           346284 kB
Inactive:         497060 kB
Active(anon):     146212 kB
Inactive(anon):   197168 kB
Active(file):     200072 kB
Inactive(file):   299892 kB

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .