

It should be noted, however, that a low to moderate level of usage of swap memory that is not actively being used is no cause for concern whatsoever.

(Amongst others – the OOM (out of memory) killer will start to kill processes based on, among other criteria, the amount of memory they initially requested – which means that the server process that is the whole point of the server is likely to be one of the first to die.) If your swap usage is high – that can be dangerous, as it means the system is in danger of exhausting all the memory – and then if a program needs more, and is unable to get it, Bad Things happen. So even though 90% of the total virtual memory space is in use (counting both swap and physical) there has never been a time when the system ran low enough on physical memory that it couldn’t free some from the file cache, and had to put some on swap. So looking at the outputs above, we can see that the system has used zero swap space.

To see the amount of swap memory in use, you can also use top or the free command $ free -t In any event, so long as there is free virtual memory, and not active swapping, you will be OK with highly utilized physical memory. It’s better to have some file cache in most situations: but not if you are running a large Java program, and want to maximize the heap or a database, and you want the database to manage disk caching, not the OS (as the database has more knowledge about the utilization of the data.) So memory used by the file cache is free (from the point of view of being available for allocation to programs) but serving a useful purpose until it is needed by a program.Įven if all Linux memory is used, and very little is free or in use as a file cache – that can be OK. But if programs need that physical memory, the kernel will reallocate the file cache memory to the programs. Linux uses all physical memory that is not needed by running programs as a file cache, for efficiency.

The file cache does what it sounds like – caches in memory recently accessed files – meaning that if a program requests access to a file that is in the file cache, no disk access is required. Almost half the memory on this system is in use: but by the file cache. Think of ‘free memory’ in Linux as ‘wasted memory’ (or better ‘memory the operating system has not yet been able to take advantage of’). Some people may see the output of free, or the above graph, and react with “1G on my 48G system is all that’s free? I’m out of memory!” This is a natural reaction – but wrong. Or you can use your handy monitoring system to view this over time: There are three things that may spring to mind when you think of measuring your memory system:įor physical memory usage, you can run top or free from a shell: $ free -g Now I’ll talk about how to monitor virtual memory, on Linux (where it’s easy) and, next time, on Solaris (where most people and systems do it incorrectly.) Running programs that require more memory than the system has will mean pages (or processes) are moved to/from disk and memory in order to get enough physical memory to run – and system performance will suck.) (TL DR: swapping is moving an entire process out to disk paging is moving just specific pages out to disk, not an entire process. In a prior blog post, I talked about what virtual memory is, the difference between swapping and paging, and why it matters.
