Solaris Paging and Memory Management
Traditional Paging - LRU Algorithm (Least Recently Used)
The traditional Unix paging model used the Least Recently Used algorithm to select pages eligble for paging. Levels of memory utilisation are set, below which, a scanner program starts selecting pages to be paged out. With older versions of Solaris three levels were defined. Problem: The problem with this model is that if there's a lot of filesystem I/ O , a lot of the filesystem pages are cached in memory. This can cause the available memory to fall below lotsfree which can lead to application pages getting paged out instead of filesystem pages, leading to degraded application performance.
With the release of Solaris 7, priority paging was introduced ( it was also back ported to Solaris 2.6 and 2.5.1). This went some way to resolving the issues with LRU paging by introducing a new memory utilsation level.
Solaris 8 Cyclical Page Cache
A separate free list, filesystem free list, was introduced with Solaris 8 so that file system caching is treated totally separately from other objects in virtual memory. This means that heavy filesystem I/O does not result in application pages being forced out of memory With Solaris 8, vmstat -p will show filesystem paging as separate columns. Some of the more useful fields displayed are as follows:
Solaris Memory Utilisation
As previously mentioned, memory is used for file buffering, the kernel and applications. The following tools can be used to measure memory utilisation by each area
- prtconf - Total physical memory
- prtmem (From Memtools package) - File buffering memory
- sar -k 1 1 - kernel memory
- vmstat - free memory (usually near to zero as free memory is used for file buffering
A memory shortage is usually indicated by excessive paging. Using vmstat check the scan rate (sr) and page out (pr) columns. If the values are continously over 20 there's probably a memory shortage. If sr is 0 there's no memory issues. Another way to check for memory issues is to look for excessive I/O on the swap device Another way a memory shortage can reveal itself is applications failing upon start up. When a process starts, it tries to reserve the amount of memory it will require from the virtual memory total ( real memory plus swap). If there's not enough memory available it will fail immediately (rather than failing half way through doing something…).
How much memory is an application using?
To check application memory utilisation you use either pmap -x pid or pmem pid A totals line will be shown. The resident memory total is the total real memory the process is using. However, the shared memory figure is the amount shared with other processes (e.g. system libraries, executables) so the private memory figure is the amount of memory used exclusively by this process. The first instance of a process will use the amount of memory shown by the resident memory total. However, another instance of the same process will only occupy the extra memory shown by the private memory figure.