[SunHELP] Running out of swap when real memory is available

Adrian Florea Adrian.Florea at alcatel.ro
Fri Sep 30 09:49:12 CDT 2005

I think you'll find this doc useful (from SunSolve)

*Document Audience:* 	SPECTRUM
*Document ID:* 	72971
*Title:* 	How does Solaris[TM] Operating System calculate available swap?
*Update Date:* 	Wed May 04 00:00:00 MDT 2005
*Products:* 	 Solaris 8 Operating System,  Solaris 9 Operating System, 
 Solaris 7 Operating System,  Solaris 10 Operating System,  Solaris 2.6
*Technical Areas:* 	 Kernel


*Keyword(s):*swap, swapfs, swapfs_minfree, tmpfs


When configuring swap space on a system, it is useful to know how
Solaris[TM] Operating System calculates available swap.

*Document Body:* 	

Swap size is equal to all available physical memory (RAM swap) plus any physical
disk partitions dedicated for swap, plus space allocated to swap in the form of

The amount of memory available for RAM swap is less than the size of physical
memory. This is because only pageable memory is available for RAM swap. 
Memory that is not pageable includes most of the kernel, any memory that is
mlock()ed and intimate shared memory (ISM).

You can see the summary of memory by running "netstat -k system_pages" or
"kstat -n system_pages".

Note that the -k option to the netstat command is undocumented and its use is
deprecated. In Solaris 10 the -k option is unavailable and "kstat -n
system_pages" must be used. The output format of "kstat -n" differs from that of
"netstat -k" however all the values of interest are present in "kstat -n" output
and have the same names as they do in the output of "netstat -k" with the
exception of "pages total" which is renamed "pagestotal".

The discussion below uses "netstat -k"; similar values for "pp_kernel",
"pageslocked" and "pagestotal" would be displayed by "kstat -n system_pages".

% netstat -k system_pages

physmem 15153 nalloc 5931096 nfree 5868115 nalloc_calls 3092 nfree_calls
kernelbase 268463432 econtig 280756224 freemem 1719 availrmem 11932
lotsfree 236 desfree 118 minfree 59 fastscan 7568 slowscan 100 nscan 0
desscan 25
pp_kernel 2773 pagesfree 1719 pageslocked 3204 pages total 15136
^^^^^^^^^^^^^^                ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^

The kernel on this 128MB machine is 2773 pages, or 21MB, and the
total size of locked memory (including the kernel) is 3204 pages, 25MB
(Note that on Solaris 10 and above, pp_kernel excludes pageslocked,
and thus they must be added).  A page is 8KB (8192 bytes).

One would expect this machine to have a virtual swap size of: 128MB - 25MB =
Note however that "pages total" is 15136 pages which corresponds to 118MB and
not the 128MB of physical memory installed. 

During boot, some of the system's memory is used for statically-allocated
portions of the kernel, such as the kernel text, TSBs (translation storage
buffers), page structures, the page table, etc.  Memory left after those
allocations is shown in the physmem above.  In this case, there is 118MB (15153
* pagesize, or 8KB) memory for which page structures are created  (Note that
on Solaris 10 and above, this memory is already accounted for in pp_kernel).

So, we have 118MB - 25MB = 93MB of pageable virtual memory, but there is one
last factor. The swap file system leaves a reserve of 1/8th of memory, or 118/8
= 14.6MB.  The minimum for this is 2MB.


        Total Memory            128MB
        - static kernel          10MB
        - Kernel                 25MB
        - swapfs_minfree         15MB
        ---------------------   -----
        Total Ram Swap           78MB 

Total Swap space = Ram swap + disk swap

How to read df -k /tmp output:

Filesystem            kbytes    used   avail capacity  Mounted on
swap                   52280     664   51616     2%    /tmp

tmpfs (when mounted on /tmp) dynamically changes its size depending upon how
much memory (or swap) is available.

The "kbytes" column in "df -k /tmp" output is the amount of swap space
available, rather than the total. 

The tmpfs file system also has a minfree, so the total is slightly less than the
amount of swap available. "kbytes" column of "df -k /tmp" output actually
correspond to "swap -s" output of swap available. Normally, these two numbers
are pretty close.

The difference is due to the tmpfs_minfree value, which is 2MB by default.

% swap -s
total: 120272k bytes allocated + 26696k reserved = 146968k used, 53696k

If some process would de-allocate some swap, and swap -s would show more swap
available, then the df -k /tmp would also show that its total file system size
has increased.

Naresh Narang wrote:

>Hi there,
>	Thanks for your response. Let me put my question in a different way.
>	I have 8 G memory available on the box, why Solaris 10 does not want to use
>more than 4 G.
>-----Original Message-----
>From: sunhelp-bounces at sunhelp.org [mailto:sunhelp-bounces at sunhelp.org]On
>Behalf Of Mr Rene Occelli
>Sent: Wednesday, September 28, 2005 11:21 PM
>To: sunhelp at sunhelp.org
>Subject: Re: [SunHELP] Running out of swap when real memory is available
>I'm not a specialist, below what I have understood
>Because Solaris uses real memory to swap when memory is available
>you can see this with swap command
>Loem%swap -l
>swapfile             dev  swaplo blocks   free
>/dev/dsk/c0t0d0s1   32,25     16 4090800 4090800
>Loem%swap -s
>total: 451352k bytes allocated + 19488k reserved = 470840k used, 3031744k
>-----> remark  3Gb available
>Hope this helps
>R Occelli
>-----Original Message-----
>From: sunhelp-bounces at sunhelp.org [mailto:sunhelp-bounces at sunhelp.org]On
>Behalf Of Naresh Narang
>Sent: Wednesday, September 28, 2005 6:39 PM
>To: sunhelp at sunhelp.org
>Subject: [SunHELP] Running out of swap when real memory is available
>Hi Managers,
>	Why I run out of swap when real memory is available.
>#uname -a
>SunOS XXX 5.10 Generic sun4u sparc SUNW,Ultra-Enterprise
>Thanks for your help.
>SunHELP maillist  -  SunHELP at sunhelp.org

More information about the SunHELP mailing list