4 Replies Latest reply: Nov 8, 2011 4:43 AM by 897989 RSS

    Virtual memory in Solaris container

      Hi guys,
      I have an question regarding local zones virtual memory.
      I have given this configuration:

      physical: 1G
      [swap: 2G]

      If my understanding is well so whole amount of virtual memory should be 3GB.

      On the Internet I found this question where is by writer mentioned this suggestion:

      "*From the my (pre-container) point of view, "zone.max-swap" would mean the amount of disk space available for virtual memory* (i.e. swap device size), but all memory allocation tests I have run (pinched from google'ing - C (using calloc), Java (using -Xms/-Xmx options) and Perl (appending to a large string)) *are pointing to it meaning total memory (i.e. physical + disk-based)*"

      For full info see link below:

      virtual memory, swap and zone.max-swap definitions

      So my question is, is in the configuration mentioned above "swap: 2G" the whole amount of virtual memory, or this is just one part of it (second part is "physical: 1G") ??

        • 1. Re: Virtual memory in Solaris container
          Your understanding is correct, the virtual memory in Solaris consist of two things, the RAM and the Swap Space. In your case the Total Virtual Memory would be 3 GB, consisting of 1 GB RAM and 2 GB swap.

          • 2. Re: Virtual memory in Solaris container
            What makes me little bit confused is :
                 physical: 4G
                 [swap: 8G]

            bash-3.00# swap -l
            swapfile dev swaplo blocks free
            /dev/swap 4294967295,4294967295 16 16777200 16733328
            16777200/2/1024= *8191.9921875MB* <-- at all
            16733328/2/1024 = *8170.5703125MB* <-- of swap is currently free

            bash-3.00# swap -s
            total: 21928k bytes allocated + 0k reserved = 21928k used, 8366680k availabl0e
            (21928 + 8366680)/1024 = *8192MB* <-- looks OK

            Not sure if output from vmstat is telling true or if I have just wrong understanding of his output:

            bash-3.00# vmstat 3
            kthr memory page disk faults cpu
            r b w swap free re mf pi po fr de sr s0 s1 s2 sd in sy cs us sy id
            0 0 0 13106456 5976648 35 72 0 0 0 0 0 33 32 -0 -0 418 1082 316 0 1 99
            0 0 0 *12883744* *5686072* 2 5 0 0 0 0 0 0 0 0 0 210 332 1 0 0 100
            0 0 0 12883552 5685880 1 2 0 0 0 0 0 0 0 0 0 210 333 2 0 0 100

            For free column:
            5686072/1024 = *5552.8046875* (Can I understand this number as that this system has currently 5552 MB from (8GB + 4GB) 12 GB virtual memory free???)

            But what is exactly output for swap column??
            In man vmstat is written "swap available swap space (Kbytes)), from that:
            12883744/2/1024 = *6290.890625 MB*, respectively *6290MB* of 8GB swap is free
            But output from swap -l upstairs show us 16733328 blocks (16733328/2/1024) = *8170.5703125 MB*

            Not sure whats more trustworthy???

            Is there any recommended way how can I get particular amount of virtual memory (RAM + swap together) and current utilization in local zone ???

            Thanks for your help

            Edited by: user13070240 on Nov 7, 2011 9:15 AM
            • 3. Re: Virtual memory in Solaris container
              Well, i think they are all right, but they all report different things.

              The Solaris Virtual Memory mechanisms tends to be a source of confusion when you start to look at them.

              Swap -l reports the size of your swap, in 512-byte blocks, just as you figured, whereas vmstat reports it in bytes.

              Solaris will try to use your RAM/Swap space to cache things, such as data, files, filestructures, directories and ZFS data, this means that some swap/RAM will seem used when its in fact only used for cached data, which means that when an application wants to use memory, the Solaris kernel will handle it memory which was previously used by caches.

              So there is nothing alarming with low memory figures, it just means that the kernel is making use of that expensive RAM. You will probably only see a low RAM utilization on a system which is recently booted.

              One thing to look at regarding the Solaris Virtual Memory is the ARC cache, which is the ZFS cache, there is a tool somewhere which is called arcstat.pl, which will tell you the usage of the ARC cache.

              Also, the "free" column from vmstat is the freelist, which is the amount of instantly available RAM, if a process would require more than that the kernel would have to reclaim some RAM which is used by a cache.

              The next column, re, is actually quite interesting in this sence, it shows the amount of pages which was reclaimed, i.e pages which for some reason where put on the freelist (perhaps the application which were using it exited), but then reclaimed (i.e another application were started which requested the same data and got it from RAM, since the page had been marked 'free' but not emptied.. (a typical example of this is 'ls', if you reboot a system the first 'ls' tends to be rather slow, but the next ones will always be faster).

              Even though for memory usage vmstat -s is somewhat more useful.

              Its also more useful to use vmstat to figure out how the system is claiming memory, for instance its a good thing to keep an eye on the pi/po columns (page in and page out), to see if the system is paging..

              If you run vmstat -S you will also see if there is any swapping (which occours if the kernel is really low on Virtual Memory and have to start writing processes (actually LWP's) to the swapspace in order to free RAM).

              Ok, i'll stop myself now, since its rather late..

              • 4. Re: Virtual memory in Solaris container
                Hi abrante,
                many thanks for your effort.
                Seems to be clean now, but maybe I have one more question regarding understanding of vmstat output.
                As you said "whereas vmstat reports it in bytes", but in man pages is mentioned (Kbytes)

                If I take for example this sample...

                bash-3.00# vmstat 3
                kthr memory page disk faults cpu
                r b w swap free re mf pi po fr de sr s0 s1 s2 sd in sy cs us sy id
                0 0 0 12899256 5705808 3 5 0 0 0 0 0 3 3 -0 -0 226 84 25 0 0 100
                0 0 0 *12880208 5681040* 2 5 0 0 0 0 0 0 0 0 0 209 332 1 0 0 100

                For free memory (I supposed that this is physical memory, so RAM):
                5681040 kilobytes = *5547.890625 Mb* -> for me sounds bad that system with 4GB RAM show almost 5,5GB memory free

                Similar for swap:
                12880208 kilobytes = *12578.328125 Mb* -> system has 8 GB swap, so it looks rather like whole virtual memory (4 GB RAM + 8 GB swap see below)

                bash-3.00# swap -l
                swapfile dev swaplo blocks free
                /dev/swap 4294967295,4294967295 16 16777200 16733328

                16733328/2/1024 = *8170.5703125*

                Not sure, but maybe I'm doing something wrong in computation, or my understanding of swap and free columns in vmstat is still wrong ;o(
                Can I ask you maybe for example of calculation?

                Ones more many thanks for your help, I really appreciate it.