Category : Knowledge
I have recently been using Windows to tune a Java application I created to move large amounts of data into a database. The application was very memory hungry as it implemented various queues to buffer incoming data before committing it to the data target.
This meant that I needed to understand the memory which was being used at any given point, both in the JVM and on the operating system itself. On the Windows side, the Task Manager has many extra columns which can be added to the Processes tab to see exactly what each process is doing, and how much resource it is costing to do it.
The CPU and IO columns should be fairly straight forward however the memory columns can be most confusing. Before we can get into it there are a few terms which you must understand
- Physical memory – this is RAM, physical memory which you have installed in your machine. This is the fastest type of memory and also the most expensive. Physical memory will be used for all your processes memory requirements unless you run out or the operating systems decides to free some for other things.
- Virtual memory – when you run out of physical memory and another process asks for more memory the operating system needs a mechanism to ensure the requirements can be met. Virtual memory is used much the same as RAM however it is stored on a disk. Disks, even SSDs, are very slow compared to RAM and come with a huge performance impact. Your operating system will move RAM to virtual memory when a process hasn’t been used for a while, or if sacrifices need to be made to free some RAM for something else.
There are many memory related columns in Windows Task Manager which all have subtly different meanings. Here are some of the most common and useful memory column definitions:
- Memory – Working Set – is the total amount of memory used by the process which is private and unique to the process as well as shared memory used by the process such as shared libraries.
- Memory – Private Working Set – is the amount of memory used by the process which is unique to the process and cannot be accessed by other processes.
- Memory – Peak Working Set – is the most memory, both unique and shared, which has been used by the process since it started. This is reset each time the process ends.
- Memory – Commit Size – is the amount of virtual memory which is reserved, or committed, for the process.
- Page Faults – is the amount of times memory has been fetched from virtual memory because it was not found in physical memory. This is a counter and similar to Memory – Peak Working Set in that it is reset each time the process ends.
By understanding an monitoring these values you can get an understanding of what a processes is doing with it’s memory.