LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-22-2009, 04:23 AM   #1
rabbit00
LQ Newbie
 
Registered: Mar 2009
Posts: 8

Rep: Reputation: 0
Swap space did not function when physical memory ( RAM ) is full


Hi all,

The swap space did not function ( usage stay 0% ) when physical memory (RAM) is full. This cause the workstation hang.

Workstation model = xw4400
Physical memory size = 4G
Swap Space size= 4G ( 2G on each HD ).

Would like your help as following :-
1. Why the swap space did not function when physical memory is full ?
2. How to activate the swap space to function when physical memory is full ?
3. Any command to clear / initialize the RAM ?




free

total used free shared buffers cached
Mem: 4095376 4011452 83924 0 48808 2469584
-/+ buffers/cache: 1493060 2602316
Swap: 4096524 0 4096524



/proc/swaps
Filename Type Size Used Priority
/dev/sdb1 partition 2048248 18760 -1
/dev/sda2 partition 2048276 0 -2



/etc/fstab

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home /home ext3 defaults 1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sdb1 swap swap defaults 0 0
/dev/sda2 swap swap defaults 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
 
Old 06-22-2009, 04:51 AM   #2
DragonSlayer48DX
Registered User
 
Registered: Dec 2006
Posts: 1,454
Blog Entries: 1

Rep: Reputation: 75
What distro and version are you using, and how was the drive partitioned?

I can't read your fine blue print, but it sounds like the swap space didn't get flagged as such. They need to be set as linux-swap by the partitioner.
 
Old 06-22-2009, 04:51 AM   #3
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
What does the output of swapon -s give? Is the swap space actually on?
 
Old 06-22-2009, 04:57 AM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
But it is used, at least /dev/sdb1:
Quote:
/proc/swaps
Filename Type Size Used Priority
/dev/sdb1 partition 2048248 18760 -1
/dev/sda2 partition 2048276 0 -2
from man fstab
Quote:
The second field, (fs_file), describes the mount point for the filesystem. For swap partitions, this field should be specified as `none'.
So, your swap lines should read:
Code:
/dev/sdb1 none swap defaults 0 0
instead of:
Code:
/dev/sdb1 swap swap defaults 0 0
with regard to the second field.

Actually, my entry differs at the fourth field as well - I have "sw" there instead of "defaults", like this:
Code:
/dev/sdb1 none swap sw 0 0
HTH
 
Old 06-22-2009, 05:16 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Why do you think your RAM is "full" ?.
Why do you think your swap isn't being "used" ?.

How is any of this affecting your machines performance ?.
 
Old 06-23-2009, 12:47 AM   #6
rabbit00
LQ Newbie
 
Registered: Mar 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Hi all,

Thanks for the reply.

To dragonslayer48dx
Software : Linux Redhat 3 ( Taroon Update 7 )

HD partition :
/dev/sda
- sda1 102MB ext3
- sda2 2000MB linux-swap
- sda3 74214MB ext3
/dev/sdb
- sdb1 2000MB linux-swap
- sdb2 74316MB ext3
Note : The partition is auto partition during redhat installed with recovery disk.

To PWC101
swapon -s result is /proc/swaps file content ie.
Filename Type Size Used Priority
/dev/sdb1 partition 2048248 18760 -1
/dev/sda2 partition 2048276 0 -2

How to check whether the swap is on ?

To jomen
Did modify the fstab top portion before. It will cause all system cannot be boot up.
Only can recovered by new installation.

To syg00
Actually this workstation is used for test system.
During the program running. We open the info centre ( memory ) to do the monitoring.
We can notice the physical memory free space is slowly reduce from about 2G to 200M and then workstation hanged.
For the swap space memory. The usage is keep on 0%.
The testing speed is getting slower and slower ( from initial 20sec per test to 200sec per test ) and finally workstation hanged.



free
total used free shared buffers cached
Mem: 4095376 4011452 83924 0 48808 2469584
-/+ buffers/cache: 1493060 2602316
Swap: 4096524 0 4096524


/proc/swaps
Filename Type Size Used Priority
/dev/sdb1 partition 2048248 18760 -1
/dev/sda2 partition 2048276 0 -2


/etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home /home ext3 defaults 1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sdb1 swap swap defaults 0 0
/dev/sda2 swap swap defaults 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
 
Old 06-23-2009, 12:57 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Your swap is active else you wouldn't see it via "swapon -s" - but it is only used for dirty anonymous (malloc'd) memory.
See if you can get these commands to run just before a hang, and post the output
Code:
cat /proc/meminfo > meminfo.txt
cat /proc/slabinfo >> meminfo.txt
 
Old 06-23-2009, 03:56 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by rabbit00 View Post
free
Code:
total used free shared buffers cached
Mem: 4095376 4011452 83924 0 48808 2469584
-/+ buffers/cache: 1493060 2602316
Swap: 4096524 0 4096524
Your RAM isn't "full" ... you have got almost 2.5GB
free (kind of) that Linux just uses to cache files.



Cheers,
Tink
 
Old 06-23-2009, 04:45 AM   #9
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
Did modify the fstab top portion before.
You mean the lines pertaining to swap?
Quote:
It will cause all system cannot be boot up.
That _is_ stange then.
If an entry like
Code:
/dev/sdb1 swap swap defaults 0 0
works for you, then an entry like
Code:
/dev/sdb1 none swap sw 0 0
should work, too.
Quote:
Only can recovered by new installation.
Sorry - but I highly doubt that.
 
Old 06-23-2009, 05:14 AM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
The following is a simplified version of the true behavior, but explains the important issues:

Most pages in memory are unmodified copies of pages in files on disk, for example the executable code of whatever programs are running.

Many of those unmodified pages aren't even mapped into the address spaces of tasks, they are just cached because they were read fairly recently and might get read again.

When memory is "full", the system must free some pages. It tries to free pages that have not been used recently, but with some amount of bias toward freeing pages that are unmodified copies of pages on disk.

If it happens to decide to free a page that is not an unmodified copy of disk, it will need to write that page to swap space before really freeing it, and later will probably need to read it back from swap space.

If it decides to free an unmodified page, it can immediately free that page. If the page is needed in memory again later, the system can read the page again from wherever it is on disk.
 
Old 06-23-2009, 05:22 AM   #11
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by rabbit00 View Post
Actually this workstation is used for test system.
Testing what?

Quote:
We can notice the physical memory free space is slowly reduce from about 2G to 200M and then workstation hanged.
I would need to see the output from free before and after a significant fraction of that reduction to reach any conclusions about what it means. The info you provided tells less than you think it tells.

Quote:
The testing speed is getting slower and slower ( from initial 20sec per test to 200sec per test ) and finally workstation hanged.
Based on what you said so far, I would not guess anything is wrong with the swapping and I would not guess that the hang was caused by physical memory being full.

Zero swapping is probably a correct behavior under these conditions.

My guess at the leaking resource causing the problem is virtual memory, not physical memory. But without more info, that isn't more than guess and I don't know which virtual memory.

Quote:
During the program running.
Quote:
The testing speed is getting slower and slower
Is each test a whole run of the program start to exit? Or is it an operation within an already running program?

The second allows for very simple and common problems exhausting the virtual memory within that program. The first would require a much more drastic bug to exhaust any resource.

BTW, the info you displayed from free showing zero swap use was inconsistent with the info you displayed from other tools that showed minimal swap use. I assume that is not a symptom of any complicated issue, but just means you ran free under different conditions than the other tools.

Last edited by johnsfine; 06-23-2009 at 05:32 AM.
 
Old 06-23-2009, 11:01 AM   #12
rabbit00
LQ Newbie
 
Registered: Mar 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Your swap is active else you wouldn't see it via "swapon -s" - but it is only used for dirty anonymous (malloc'd) memory.
See if you can get these commands to run just before a hang, and post the output
Code:
Currently the workstation is temporary running other devices.
Already do a cron job to execute the code given for every 1 mins.
Will try to get the information once the workstation is available for debugging.


Quote:
Your RAM isn't "full" ... you have got almost 2.5GB
free (kind of) that Linux just uses to cache files.
Is it mean that after the physical memory is full, it will start using cache files then swap space ?


Quote:
Testing what?
This workstation is used for ATE ( Automatic test equipment ).
It's test wafers and IC chips.


Quote:
Is each test a whole run of the program start to exit? Or is it an operation within an already running program?
The program ( test program )is never exist during test the IC chips.
The sequence of testing is Received IC chips --> start test --> end test --> change another chips --> start test --> end test... until finish testing all IC chips. then the program is existed.


Quote:
BTW, the info you displayed from free showing zero swap use was inconsistent with the info you displayed from other tools that showed minimal swap use. I assume that is not a symptom of any complicated issue, but just means you ran free under different conditions than the other tools.
Yes, you are correct. The "free" is ran during the program is half-way running ( approaching physical memory full ). Anyway, we are not able run the "free" when the workstation is hanged.
 
Old 06-23-2009, 02:14 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Well ... to find out what the memory status was at death
you could do something like this (assuming you've set-up
password-less ssh authentication for a user on the test
machine to some other Linux box):
Code:
watch -n 1 'free | ssh user@otherbox "cat >> ~/memory_use"'
And then watch how it goes.



Cheers,
Tink
 
Old 06-23-2009, 02:17 PM   #14
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by rabbit00 View Post
Is it mean that after the physical memory is full, it will start using cache files then swap space ?
The Linux kernel is pretty good at making guesses
what makes most sense in terms of using RAM efficiently.

Only when processes really need RAM it will take sensible
caching away. Chances are it will put some less used
code into swap before cache decreases. However, you will
not see an out of memory condition w/o having even touched
swap.



Cheers,
Tink
 
Old 06-23-2009, 04:20 PM   #15
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I now think you are running out of kernel virtual memory or some resource closely related to kernel virtual memory.

I don't know how to report on usage levels of those resources. Maybe someone else here does.

I don't think you are running out of user mode virtual memory, because you said the whole system is hung, you can't even use free.

I don't think you are running out of physical memory, because
Quote:
The "free" is ran during the program is half-way running ( approaching physical memory full )
was far short of half way to physical memory full even assuming the swapping system is broken and shows no evidence it is even on its way to physical memory full.
Plus, there is no hint (other than your unsupported guess) that anything is wrong with the swapping system. With 4GB of swap under the conditions you describe, the system would slow down gradually. There would be plenty of time to run free after the system was quite sick, but before the system was too hung to even run free.

So that leaves some kernel resource based on kernel virtual memory limits.
 
  


Reply



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
Top shows virtual memory use by proccess more than physical RAM! help! aznblood Linux - Software 2 08-21-2008 09:19 AM
my physical memory just get full hua Slackware 15 06-28-2007 03:50 PM
how to use swap more than the physical memory Santosh_d Linux - General 9 03-24-2004 02:51 PM
swap drive, physical memory glock19 Linux - General 6 03-08-2002 04:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:51 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