Help understanding how swap works


 
Thread Tools Search this Thread
Operating Systems Solaris Help understanding how swap works
# 1  
Old 11-29-2013
Question Help understanding how swap works

Hi all,

I'm trying to get an understanding of swap. This is what I see:

Code:
Memory: 8192M real, 1697M free, 5693M swap in use, 10G swap free

My question(s): If I have available RAM, why am I using swap? Or am I reading this wrong (been known to happen).

Thanks much,

~K
# 2  
Old 11-29-2013
It's not 'used' as in 'the system is desperately out of RAM and turfing things onto disk to make room', but 'used' as in 'we have 5 gigabytes of swap reserved to match currently allocated memory'. Most UNIX systems reserve swap in advance, so that if conditions suddenly do become tight, the system doesn't find itself overextended i.e. there's more RAM been given away than it has swap space to deal with.
These 3 Users Gave Thanks to Corona688 For This Post:
# 3  
Old 11-29-2013
I think that you're asking why, when you have RAM free, is there so much "swapped out".

The answer is that swap space is managed by the Operating System and is used as an extension of RAM. Otherwise the system would run out of RAM at some point especially when new processes need RAM space to launch.

However, if the working set (or part of a working set) is kicked out of RAM into swap space to make room for somebody else, the process swapped out will not be swapped back into RAM unless there is a need (ie, the process is ready to run). There may be no need to swap a process back in if, for example, it is waiting for I/O (to disk or network) to complete.

So, for example, a large new process starts which causes several other processes to be swapped out. That large process then finishes releasing RAM but there may be no need at that time to swap any processes back in. Hence, some RAM is free but swap space usage is high(er).

I don't know whether I've explained that clearly enough. Does that help?
This User Gave Thanks to hicksd8 For This Post:
# 4  
Old 11-29-2013
Awesome. Makes more sense now. Many thanks to you both!
# 5  
Old 11-29-2013
Good.

Ever left your terminal waiting for keyboard input and gone out to lunch?
# 6  
Old 11-29-2013
It's not a practice to do so. Why?
# 7  
Old 11-29-2013
Well that's a typical example of when a process is suspended for a whole hour waiting for I/O (from the terminal keyboard) which makes it an ideal candidate to be kicked out of RAM when RAM space is tight, and with no need to be swapped back in until you come back, sit down, type something and hit return.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Help in understanding how backup and restore works in any organization?

Please take your time to answer/comment. no urgency. it would help upcoming sysadmins like me in understanding how things work in real time. OS: AIX Middleware: Weblogic/WAS Database: Oracle DB/IBM DB2 Backup s/w tools: not available as of now (except native OS commands/utilities) I'm a... (5 Replies)
Discussion started by: aaron8667
5 Replies

2. Solaris

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... (6 Replies)
Discussion started by: seenuvasan1985
6 Replies

3. Solaris

Help on Understanding Swap Size

Hi All, I want to know how to understand the actual swap size. My o/p shows as below root@ecovs1a # swap -s total: 4546056k bytes allocated + 358856k reserved = 4904912k used, 5046688k available root@ecovs1a # swap -l swapfile dev swaplo blocks free /dev/md/dsk/d31 ... (9 Replies)
Discussion started by: vivek.goel.piet
9 Replies

4. UNIX for Advanced & Expert Users

How this works?

I have a program............ #include<stdio.h> #include<unistd.h> main() { if(fork == 0) { printf("Hi every body:p!!!!!!!!!!"); } } This program works with out any error. here fork is not a system call. It just act as a variable.But how it works without declaring it? What data type it... (19 Replies)
Discussion started by: carolsanjeevi
19 Replies

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

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

7. UNIX for Dummies Questions & Answers

>./a.pl works, >a.pl - does not

When I try to execute script, I get message: >aa.pl zsh: command not found: aa.pl but >./aa.pl works OK. What to change in environment to force the former way to work? Thank you, Alex Z (4 Replies)
Discussion started by: zzol
4 Replies

8. Programming

how this works?

pls explain me how this works.... DECODE (SUBSTR (field, 1, 1),'''', '''''' || field || '''','''' || field || '''') here field is a column in an oracle table.... (7 Replies)
Discussion started by: vijay_0209
7 Replies

9. UNIX for Dummies Questions & Answers

How ls | wc -l works?

ls displays files in tabbed output. Say a directory contains 3 files. ls will list all 3 in one line. So, I expect ls | wc -l to give 1, but it counts the nr of files and gives 3. Can someone explain how this works? (3 Replies)
Discussion started by: krishmaths
3 Replies

10. 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
Login or Register to Ask a Question