Explain the output of swap -s and swap -l

Hi Solaris Folks :),

I need to calculate the swap usage on solaris server, please let me understand the output of below swap -s and swap -l commands.

$swap -s
total: 1774912k bytes allocated + 240616k reserved = 2015528k used, 14542512k available
$swap -l
swapfile             dev  swaplo blocks   free
/dev/md/dsk/d31     85,31     16 20972720 20972720

Expecting some deep explanation :b:.

Regards,
Sri

Hello,

Here is the explaination by man swap . I think it is easy to understand too.

Thanks,
R. Singh

As per this, I believe

The total virtual memory =

2015528k used + 14542512k available + 8GB physical memory 

Allocated disc swap space = total: 1774912k bytes allocated + 240616k reserved
So final available swap space = swap -l output + Physical memory.

Hence available swap = 20972720 + 8GB Physical = 28GB ???

Totally confused ...:frowning:

Hello seenuvasan1985,

From swap -l you have just one swap file. You could define more if you need them.

The swap size is 20972720 x 512 byte blocks, or in the region of 10Gb depending how you count/round it.

The swap file is on disk. Real memory is chips on a card (or cards) on the system bus and we will ignore CPU based cache.........

Virtual memory is, well, depending on your definition either either the total of the two or just the swap space.

Does that clarify things?

Are you actually trying to work out something else? Perhaps if you give us the question, we can understand what you need to know.

Robin

The main issue is depending on the option used, the swap command is about two quite different concepts.

  • "swap -l" is telling the size of the swap area(s) and how much of it is storing actual data. In your example, you have a 10 GB raw device which contains absolutely no data.
  • "swap -s" is telling statistics about the swap space. The latter represent the virtual memory the userland processes and some kernel components use on this system.

In your example you have roughly 16 GB of virtual memory, from which:

  • 1.7 GB contains data that need to remain stored whether in RAM or on the swap area (in your case, everything in on RAM)
  • 240 MB is reserved virtual memory, i.e. memory that contains nothing but cannot be allocated being owned by processes which might store something there in the future.
  • 14.5 GB is available virtual memory

This 14.5 GB of available memory is partially RAM, partially disk (swap area) unless there is no swap area at all, not your case..

One can conclude that you have 4.74 GB of available RAM. (14.5G - 10G + 240M)

Free RAM being wasted RAM, a substantial part of this so called available RAM is containing data anyway, essentially disk cache. The difference between it and the allocated RAM is the former can be stolen instantaneously without harm, the previously cached data being still available on disk.

If we sum up the available RAM (4.74 GB) and the used RAM (1.77 GB), we get 6.5 GB of RAM. This number looks odd and there is no doubt you have more RAM installed on this machine.

My guess is you have 8 GB or RAM. The 1.5 GB difference is not part of the virtual memory. It is held mainly by the kernel and possibly by hardware components as non pageable memory, always stored in RAM.

Note also that despite being unused, your swap area has still a positive effect on your system as 250 MB of RAM would have been made unusable (being reserved) without it.

Finally, note that a portion of the processes virtual memory space is not accounted in the "swap -s" statistics, this is the memory that correspond memory mapped files.

1 Like

swap -s is confusing because it displays swapped KB plus swappable RAM KB.
According to swap -l , nothing is swapped out; the 20972720 blocks/2 = 10486360 KB = 10 GB are free.

It displays virtual memory statistics. These statistics are unrelated at all with the swap area. They would exist even with no swap area at all. Unless there is no swap area, all virtual memory is swappable (more precisely paginatable if such word exists).

Depends on how you define free. 240 MB out of these 10 GB are not free, being reserved.