LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 10-31-2007, 06:16 AM   #1
mandrake7890
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Rep: Reputation: 0
redhat never free the swap used


Hi,
We have two boxes each with Red Hat AS 4 update 4 loaded and 4 gigs of RAM. these boxes are used with Oracle RAC 10.2.0.3.0. Currently, there are many number of users accessing my RAC. I have created a dedicated server so for each I have a dedicated process. now is it good for me and at the moment at full load a create only about 200MB of swap.
My question is that in the evening when there aren't nobody on my RAC i see correctly that the amount of used ram is about 2 GB and the strange thing is that I always see 200 MB of swap used.
Is is correct ? so redhat never free the swap used ?
I can free the swap used only rebooting the two server.
I show you my top command execute on evenig
top - 12:04:06 up 13 days, 2:56, 1 user, load average: 0.82, 0.48, 0.40
Tasks: 124 total, 1 running, 123 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.8% us, 4.2% sy, 0.0% ni, 87.7% id, 5.3% wa, 0.0% hi, 0.0% si
Mem: 3984940k total, 1507856k used, 2477084k free, 126012k buffers
Swap: 4096564k total, 177924k used, 3918640k free, 963772k cached

I think that a correct output with no big load for this command is

top - 12:04:06 up 13 days, 2:56, 1 user, load average: 0.82, 0.48, 0.40
Tasks: 124 total, 1 running, 123 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.8% us, 4.2% sy, 0.0% ni, 87.7% id, 5.3% wa, 0.0% hi, 0.0% si
Mem: 3984940k total, 1507856k used, 2477084k free, 126012k buffers
Swap: 4096564k total, 0k used, 4096564k free, 963772k cached


Pls help me and sorry for my bad english
 
Old 10-31-2007, 06:32 AM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
The output you posted shows that almost no swap was being used at the time you ran the "top" command. One thing to note is that Linux and many other OSes cache disk access in ram or virtual memory (swap), so this may give the appearance that a lot of memory is being used, but in effect, its just cached stuff that is released when the memory is needed for something else. This means that there is probably no need to reboot your server unless the system is slowing down or grinding to a halt due to lack of memory.
 
Old 10-31-2007, 07:12 AM   #3
mandrake7890
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
I have undestant so and so.
You tell me that the situation that after a big workload that produce a little used swap on linux is normaly that after this workload I'll see the swap used not to 0.
So if my workload had produced a swap about 2GB I'll always see with top command that the swap used was 2GB even if the workload was terminated there is no users are using my two server.
Pls describe this situation and if there is a mode to put the swap to 0 without restart the server.
thanks
 
Old 10-31-2007, 09:12 AM   #4
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
The short answer is don't worry about it; this is perfectly normal behaviour.

A simplified example:

Let's say that you are running a large program that doesn't access the CPU much. The program code is loaded into a segment of memory that we'll call X.

1) RAM is running low, so X is copied out to disk and its RAM freed up.
2) A few milliseconds later, the program is started running again, so X is loaded into memory.
3) But the program only runs for a few microseconds and so gets swapped straight out again.

The trick is that X only contains code, which is never modifed. So when it is loaded back into RAM (2), Linux will keep the copy on the hard disk. That way when it gets to (3) it can just wipe the copy in RAM and doesn't have to write anything out to disk, which saves a significant amount of time and system load.

In general, swap space will only be freed up if the memory copy of a segment is modified (thus making the swapped-out copy useless), or if swap space is running low, so things we have copied in RAM and can't swap out need to be junked on disk in order to swap out something else.

If you really, really want to free up all available swap space then you can turn the swap space off and on again:
Code:
swapoff -a && swapon -a
Note that you should expect a minor performance penalty for having lost the data that was in swap.

There is another reason why swap space can grow, and that's because free RAM can be used to buffer disk and network input/output. So by writing data out to disk you can actually speed up performance of some other tasks, such as database access. This is called "swappiness" and can explain why used swap space sometimes goes up even if you have free RAM available.
 
Old 11-02-2007, 02:47 AM   #5
mandrake7890
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
rjlee,
many many thanks for your feedback
I have understand all
bye
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to free swap on live system? humbletech99 Linux - General 3 03-21-2007 08:04 AM
Linux crashes!!! free -m shows ZERO Swap!!! logicalfuzz Linux - General 2 01-16-2007 09:24 AM
Odd swap usage even though there is free RAM Artanicus Linux - Hardware 5 09-28-2005 02:25 AM
vm issue 2.4.26 free/swap mritch Debian 0 08-05-2004 02:26 PM
Setup free space on /dev/hdc without screwing up /swap DavidPhillips Linux - General 4 06-24-2001 10:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration