When is Swap utilised?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat When is Swap utilised?
# 1  
Old 11-26-2010
When is Swap utilised?

Hi Gurus,

I understand that swap space is utilised by the system to swap pages between RAM and swap(disk space) when there is a Memory crunch.

My question is whether the system will wait till the Memory free becomes zero to swap or will it just swap if the page remains idle.

Code:
 
[hpinadmin@MUMLHPINDBS001V ~]$ free -m -t
             total       used       free     shared    buffers     cached
Mem:       3821       3707      114          0        456       2906
-/+ buffers/cache:     344      477
Swap:       8191          0       8191
Total:       12013       3707    8306

Appended above is the output of "free" command in one of my linux servers.
The swap is not at all being utilised while as the free memory is as low as "114mb".

Does swap need to be activated?
Is the above output normal for a production server? or should i start looking to scale it up?


Thanks
HG
# 2  
Old 11-26-2010
Why do you want your swap area to be used while you still have free memory ? Also, most of the buffers and cached memory is technically free, i.e. actually available to processes should they need it.
# 3  
Old 12-01-2010
Hi jlliagre,

How are you saying that the buffers and cache are free?

What exactly does the shared/cached output mean in below output:

Code:
[hpinadmin@MUMLHPINDBS001V ~]$ free -m -t
             total       used       free     shared    buffers     cached
Mem:       3821       3707      114          0        456       2906
-/+ buffers/cache:     344      477
Swap:       8191          0       8191
Total:       12013       3707    8306


Also i was asked to get the size of each process running in this server.
I captured the RSS of each process in ps -efly output and added them(code appended below).

I ran the following command :

Code:
 
[hpinadmin@MUMLHPINAPP001V ~]$ ps -efly | awk '{print $8}' | awk '{sum = sum + $1;} END{print sum}'
670780

This adds to 670mb only. So where is the remaining Memory? If it's cached/shared,where can i find them.

Note - Please bear with my ignorance if i am asking something fundamental.

TIA
HG
# 4  
Old 12-10-2010
Swap.....

Mr Ganesh,

Within UNIX/Linux, the proverb is : "Free memory is wasted memory".

This means that all available memory goes to use within the system to serve as disk-cache, buffers, networking backing memory, etc. etc.
That is why in a UNIX/Linux system that is running for a while, the free memory counter is next to zero, and the cache and buffers counters are way up.

This is expected and approved behavior.

Swapping (or paging as is a better name for it) is not preferred behavior, since swapping pages in and out of memory is a very 'expensive' exercise in terms of time. It causes the applications to stop running, full contexts of the CPU to be flushed, active memory pages to be swapped to disk, other pages from disk to be placed in memory etc etc. this all takes a huge amount of time (CPU clocks wise..)

Before UNIX/Linux will start to swap pages in and out of memory to swapspace, the disk-cache will first 'shrink' to nearly 0, so from your 'free' output, you can count the 2.9 GB of 'cached' as free memory as well.

As for actively used memory, the RSS memory are the 'resident size' pages actively used by the application image. This is not equal to the full size the application has allocated though. Also, there is a SHR memory area, which is the Shared memory pages between the applications, this includes loaded shared libraries that multiple apps can call.

Counting the SHR + RSS and adding them up still will not get you the correctly used memory by the running apps.

However, given this 'free' output, you have nothing to worry about, and swap is correctly not used....
This User Gave Thanks to BWzes03 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Solaris

swap

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

3. Red Hat

swap

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

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

Help Me!! - AIX box utilised 100% memory for whole day

Hi, As i am new to AIX,I have a problem one of my AIX box shows 100% memory utilization for a whole day.How to find the root cause.. Note : it is a DB2 8.1 DB server. Please help Me!!:confused: (2 Replies)
Discussion started by: AIX_baby
2 Replies

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

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. Filesystems, Disks and Memory

utilised space

Is there any way out to know the utilised space in tape drive ? Thanx & Regards Gambhi. (3 Replies)
Discussion started by: gambhi_s
3 Replies
Login or Register to Ask a Question