Explain the output of swap -s and swap -l

Thread Tools Search this Thread
Operating Systems Solaris Explain the output of swap -s and swap -l
# 1  
Old 09-11-2014
Oracle Explain the output of swap -s and swap -l

Hi Solaris Folks Smilie,

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 Smilie.

# 2  
Old 09-11-2014

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

List the status of all the swap areas. The output has
five columns:
The path name for the swap area.
The major/minor device number in decimal if it is a
block special device; zeroes otherwise.
The swaplow value for the area in 512-byte blocks.
The swaplen value for the area in 512-byte blocks.
The number of 512-byte blocks in this area that are
not currently allocated.

Print summary information about total swap space usage
SunOS 5.10 Last change: 8 Aug 2008 3
System Administration Commands swap(1M)
and availability:
The total amount of swap space in bytes currently
allocated for use as backing store.
The total amount of swap space in bytes not
currently allocated, but claimed by memory mappings
for possible future use.
The total amount of swap space in bytes that is
either allocated or reserved.

The total swap space in bytes that is currently
available for future reservation and allocation.
These numbers include swap space from all configured
swap areas as listed by the -l option, as well swap
space in the form of physical memory.

R. Singh
# 3  
Old 09-11-2014
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 ...Smilie
# 4  
Old 09-11-2014
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.

# 5  
Old 09-11-2014
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.

Last edited by jlliagre; 09-11-2014 at 09:40 PM..
This User Gave Thanks to jlliagre For This Post:
# 6  
Old 09-11-2014
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.
# 7  
Old 09-11-2014
Originally Posted by MadeInGermany
swap -s is confusing because it displays swapped KB plus swappable RAM KB.
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).
According to swap -l, nothing is swapped out; the 20972720 blocks/2 = 10486360 KB = 10 GB are free.
Depends on how you define free. 240 MB out of these 10 GB are not free, being reserved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris


Hi, Can somebody please help here, since iam just a beginner. According to my book knowledge. the Avalilable memory calculated by swap -l (includes only swap) should be small as compared to swap -s value(includes Virtual memory=swap +physical). but this is quite opposite in my case. swap... (6 Replies)
Discussion started by: Laxxi
6 Replies

2. Red Hat


Hi, I have added a new disk to production server. How to make it visible to os and how to configure it. I also want to add some space from that disk to swap space. Please help me out. (1 Reply)
Discussion started by: chetansingh23
1 Replies

3. Solaris

top output and swap -s output are differing

Solaris experts, Am struggling, and wondering for the past more than one week that, how to calculate the total available and used memory/swap space. Finally installed and used top & got some understanding, but while cross-checking, there are mismatches. Main Memory top o/p - 2GB... (7 Replies)
Discussion started by: thegeek
7 Replies

4. HP-UX

Swap device file and swap sapce

Hi I have an integrity machine rx7620 and rx8640 running hp-ux 11.31. I'm planning to fine tune the system: - I would like to know when does the memory swap space spill over to the device swap space? - And how much % of memory swap utilization should be specified (swap space device... (6 Replies)
Discussion started by: lamoul
6 Replies

5. Red Hat

swap not defined as swap

free -m : 1023 total swap space created default partition /dev/sdb1 50M using fdisk. i did write the changes. #mkswap /dev/sdb1 #swapon /dev/sdb1 free -m : 1078 total swap space this shows that the swap is on Question : i did not change the type LINUX SWAP (82) in fdisk. so why is... (5 Replies)
Discussion started by: dplinux
5 Replies

6. HP-UX

How much Swap is too much?

I have a HP-UX B.11.23 server with 16 gb of memory 84 gb of swap configured. I am being pushed to define more swap to try and get more Tuxedo domains to start. At what point do we have too much swap for the amount of memory? Thanks in advance. (11 Replies)
Discussion started by: scotbuff
11 Replies

7. Solaris

Swap config - Mirror swap or not?

Hello and thanks in advance. I have a Sun box with raid 1 on the O/S disks using solaris svm. I want to unmirror my swap partition, and add the slice on the second disk as an additional swap device. This would give me twice as much swap space. I have been warned not to do this by some... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

8. Solaris

swap -l

When i try to type swap -l ,nothing come out but blinking. May i know what is the problem and solutions ? thanks (6 Replies)
Discussion started by: Farbegas
6 Replies

9. UNIX for Dummies Questions & Answers

About swap

Is it really so that if swap will be located in the begining of hard drive, than it will work faster? (1 Reply)
Discussion started by: Ty3
1 Replies

10. UNIX for Dummies Questions & Answers


When i re-updated my system i set my swap at 500 MB. I have 256 in ram and have never even gone into the 250 mb of swap that i had originally configured. How do I reduce the swap? (3 Replies)
Discussion started by: macdonto
3 Replies
Login or Register to Ask a Question

Featured Tech Videos