2nd is explaining virtual/resident set size.
2nd is explaining virtual/resident set size.
EDIT: Thank you for all the helpful responses!
> you must read a book if you want to understand it.
"Go read a book" is not a very constructive or helpful answer to a question that - as it turns out - could be answered with a brief comment.
EX: How does virtual memory get mapped to L1 cache?
The RSS thus usually indicates the amount of heap and stack a process is using that is unique to it.
This is overly simple and there are a lot of nuances such as shared memory segments, etc.
can someone explain to me why so many distros, including "enterprise" server stuff, ship with /proc/sys/vm/overcommit_memory set to 1?
- Virtual memory is basically "abstract memory" that is linked (mapped) to RAM or HDD, this means that by accessing this "memory" you might actually be accessing the HDD and, because of this, larger than physical ram.
- Virtual set size is the allocated virtual memory (the above) to the process.
- Resident set size is the allocated physical (RAM) memory to the process.
- Shared memory is memory that is shared on multiple processes, meaning that if you have 10 processes using 10mb of resident memory each and have 2mb of shared memory each, the total of resident memory used is not 100mb but 82mb.
At a mechanical level, virtual memory is permission from the operating system to use addresses in your address space. It is so called because, as you point out, it allows us to separate the concept of "memory for a process" from "physical memory on a chip." The reason I further refine the concept is that allocating virtual memory does not allocate actual memory. Let's look at an example:
void* addr = mmap(NULL, 10 * 1024 * 1024, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
That call allocates 10 MB of virtual memory. But there is no physical memory backing any of it. All that has happened is that the operating system has now said "Okay, starting at the address I return to you, you can now access 10 MB of memory. I will do all of the work of making sure physical memory backs the virtual memory when you access it." That is, once I try to access the memory, it will trigger a page fault, and the OS will find a page in physical memory to back my virtual memory. But until that happens, no memory - not in RAM, not on disk - backs the virtual memory.The rest of that document shows how to use atop to monitor per-process memory usage and identify a memory leak.
http://blogs.technet.com/b/markrussinovich/archive/2008/11/1...
(the article doesn't have an anchor there... but you know what I mean)
Would they be better at their job if they did? Probably. But do they have to? I'm not so sure anymore.
More so, I think it comes more with modern languages that don't force you to manage memory anymore. When you don't need to alloc/free everything you're using, it is easy to get lazy. Factor in never generation who've never worked outside a managed memory language. There are minute details about retaining references, having multiple copies of the same data, or other leaks (file descriptors?).
Some things about htop that I could see as friendlier:
* Htop scrolls with the arrow keys, while atop uses ^F and ^B.
* Htop displays a reminder for some commonly-used commands at the bottom of the screen (e.g. that you need to press 'F1' for help), whereas in atop you have to remember the commands or look them up by pressing 'h' or '?'.
* Htop displays gauges for system-level activity. I think this is a bad tradeoff, though:
CPU | sys 0% | user 1% | irq 0% | idle 799% | wait 0% |
MEM | tot 7.8G | free 5.7G | cache 735.6M | buff 351.2M | slab 248.1M
is much more useful than Avg[| 0.2%]
Mem[||||||||||||||||| 1008/7967MB]
There are features of htop that I wish atop had. For example, the toggleable display of threads, the tree view, and integration with strace and lsof. Even without those I find atop more useful, but YMMV.The killer feature for atop is logging per-process performance data and reviewing it after the fact.