2 Replies Latest reply on Jul 15, 2014 3:22 PM by John Riddoch

    swap space  usage




      I am facing an issue of swap space getting filled up  because of which new processes dont spawn with error  "no swap space to grow stack for pid" .Although  free main memory is available , I thought swap space is used temprarily by processes and then released .which does not seem to be the case here and it keeps on growing . Is there  a way where the swap space can get cleared  by the kernel after it reaches a certain point  Some sort of kernel parameter which triggers the OS to release the pages any process is holding as  swap THis is Soalris 10 x86 with zfs and 40GB swap is added  in root pool volumes


      Appreciate any inputs

        • 1. Re: swap space  usage
          Lars Tunkrans


             A Process does always "RESERVE"  swap space even if it does not use it.

            If  physical RAM  is much greater  than the swap space and you have  hundreds of gigabytes

            of running processes  and only 40 GB  swap space , you problem is not surprising.


          • 2. Re: swap space  usage
            John Riddoch

            Not entirely true Lars; when a process requests anonymous memory pages, these require a backing swap area to be allocated, even if it isn't used.  Anonymous memory pages include:

            - Java heap

            - DISM (Dynamic Intimate shared memory)

            - pretty much anything allocated with malloc

            It doesn't include:

            - Application binaries/libraries

            - data read from files (possibly only via things like mmap; if you malloc, read & copy into the malloc'ed area, you'll count as anonymous pages)

            - ISM (non-dynamic)


            Also, bear in mind that virtual memory is physical memory + swap partition(s) and is essentially flat memory.  This does mean that if you have e.g. 128GB physical RAM and 8GB of swap, your "backing swap" area might actually by physical RAM and ~65GB of processes will exhaust RAM.  This is particularly bad on database servers where SGA is allocated as DISM and hence requires backing store on disk or you run out of RAM very quickly.


            swap -s is generally the best report on vmem usage.


            Also, for ZFS, take care on how much is allocated for ARC cache; run this:

            /usr/bin/kstat zfs:0:arcstats:size | grep size | awk '{ printf "ZFS current ARC usage: %9d MB\n", $2/1024/1024 }'

            /usr/bin/kstat zfs:0:arcstats:c_max | grep c_max | awk '{ printf "ZFS Max ARC usage:     %9d MB\n", $2/1024/1024 }'

            /usr/bin/kstat zfs:0:arcstats:c_min | grep c_min | awk '{ printf "ZFS Min ARC usage:     %9d MB\n", $2/1024/1024 }'

            /usr/sbin/prtconf | grep Memory | awk '{ printf "Max memory:            %9d MB\n", $3 }'

            And also look into setting zfs_arc_max and zfs_arc_min in /etc/system (see Solaris tunables guide).