Hi, I'm trying to understand the various numbers reported for memory
usage from top, vmstat, and systat. I'm running OpenBSD 6.8 on a Dell
Optiplex 7040 with an i7 6700, 3.4 Ghz and 32 GB RAM. The GPU is an
Intel HD Graphics 530, integrated. Everything is running smoothly. For
my own edification, I have a few questions. I searched the mailing lists
for similar questions in the past, and found some, but they did not
fully satisfy my curiosity.

dmesg reports:
real mem = 34201006080 (32616MB)
avail mem = 33149427712 (31613MB)
I think the difference is due to the GPU reserving some memory.
Q: Is there a way to view the total amount of video memory, the amount
currently being used, and the GPU usage?

When I run top, it reports the following memory usage:
Memory: Real: 1497M/4672M act/tot Free: 26G Cache: 2236M Swap: 0K/11G
If I sum up the RES numbers for all the processes, it is close to the
act number = 1497 M (this is mostly due to Firefox). I read that the
cache number is included in tot, but even if I subtract cache and act
from tot there is 939 MB left.
Q: What is this 939 MB being used for, assuming the above makes sense?
Q: What is the cache number indicating exactly?

If I sum up tot + free * 1024 I get 31296 MB, which less than the 31613
MB of available memory reported by dmesg. I initially assumed that the
difference might be kernel wired memory. However the uvm view of systat
shows 7514 wired pages = approx 30 MB which is very small.
Q: What is the remaining memory being used for?
Q: What is in kernel wired memory? In particular, is the file system
cache in kernel wired memory or in the cache number?

In the man page for systat(1) the active memory is described as being
used by processes active in the last 20 seconds (recently), while the
total is for all processes. These are the same two numbers as act and
tot in top, and act = avm as reported by vmstat. This confused me
because adding up the RES sizes of all the processes I get nowhere near
to tot (even after subtracting cache).

There is another thing that confused me in the top output. At first I
assumed that SIZE is the total virtual memory size of the process
(allocated), while RES is the resident size. For example, this is so on
Linux and hence in that case by definition SIZE should always be greater
than RES. However here in many cases SIZE < RES.

I read in the man page for top that SIZE is actually text + data + stack
for the process. However this did not clear up my confusion or
misunderstanding. Perhaps something to do with shared memory not being
counted?
Q: How can SIZE be less that RES? An example showing how this could
happen would be really helpful.

Q: Finally, where can I find documentation about the classification for
memory pages (active, inactive, wired, etc.)? I suspect some digging
around in the source in order, but could use some pointers.

I hope these make sense and are not too pedantic. Looking forward to
comments from the experts, thanks!

Anindya Mukherjee

Reply via email to