What does Virtual memory size in top mean?

Virtual memory isn’t even necessarily memory. For example, if a process memory-maps a large file, the file is actually stored on disk, but it still takes up “address space” in the process.

Address space (ie. virtual memory in the process list) doesn’t cost anything; it’s not real. What’s real is the RSS (RES) column, which is resident memory. That’s how much of your actual memory a process is occupying.

But even that isn’t the whole answer. If a process calls fork(), it splits into two parts, and both of them initially share all their RSS. So even if RSS was initially 1 GB, the result after forking would be two processes, each with an RSS of 1 GB, but you’d still only be using 1 GB of memory.

Confused yet? Here’s what you really need to know: use the free command and check the results before and after starting your program (on the +/- buffers/cache line). That difference is how much new memory your newly-started program used.

Leave a Comment