LinuxQuestions.org
Visit Jeremy's Blog.
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 04-27-2006, 04:41 AM   #1
blnkgcrsr001
Newbie
 
Registered: Mar 2006
Posts: 18

Rep: Reputation: 0
RAM question with Linux


Is it a bad thing when RAM and Swap both get completely used up? If so, is there a command or something to free it, without having to manually delete unneeded processes (or reboot)?
 
Old 04-27-2006, 05:34 AM   #2
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
it's not a bad thing when your ram gets used - the kernel just caches a lot of stuff, and flushes the memory as it needs to (making restarting apps faster)

however, if your swap is full, then this is really bad. Your system has basically run out of memory......

how much ram do you have?

maybe you can post the output of "top"
 
Old 04-27-2006, 05:48 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
The system will take the necessary action if you don't.
There is a task known as the oom (out of memory) killer.
It determines the best task to kill to allow the system to continue running. This may not be the task you would select, so don't allow it to come to this if at all possible.

Edit: Forgot to mention you can also add more swap space - i.e. you can have more than one. Generally needs to be done ahead of time.

Last edited by syg00; 04-27-2006 at 05:52 AM.
 
Old 04-27-2006, 06:21 AM   #4
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
install & run ramdefrag
 
Old 04-27-2006, 04:02 PM   #5
visaris
Member
 
Registered: Dec 2004
Distribution: gentoo
Posts: 190

Rep: Reputation: 30
The OOM killer, lol.

I've been hit by that one before, and you are 100% correct; it doesn't usually choose to kill the process I would want to kill I doubled my RAM from 2GB+swap to 4GB+swap and the problem went away (though, I run biology simulations that eat up GOBs of RAM).



Agrouf,

It's not nice to suggest such a thing:

http://ramdefrag.sourceforge.net/sou...escription.txt
Quote:
Out there in the MS-Windows-world there are many utilities doing so-called
'RAM defragmentation', a technique which function lies solely in the users
subjective measurement of performance. These tools CLAIM to rearrange the
structures in RAM so that access to portions of the memory will speed up -
what they really DO is showing a simple progress bar and some mindless
statistics afterwards.

As more and more Windows users change to Linux nowadays, the need for a
Linux tool having the same (purely snake-oil) functionality arises. This
project is planned to take care of the problem.

Code for this project will be written in good ol' C, and as it is a
GUI-tool it will at first use GTK+ for the interface, supported by GLADE -
but maybe later versions may use qt or something alike as well. The actual
supported platform is Linux, but it should be possible to port this to any
other platform having a possibility to display progress bars.

Last edited by visaris; 04-27-2006 at 04:05 PM.
 
Old 04-27-2006, 06:24 PM   #6
blnkgcrsr001
Newbie
 
Registered: Mar 2006
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by satinet
it's not a bad thing when your ram gets used - the kernel just caches a lot of stuff, and flushes the memory as it needs to (making restarting apps faster)

however, if your swap is full, then this is really bad. Your system has basically run out of memory......

how much ram do you have?

maybe you can post the output of "top"
I have 512MB of RAM and an equal amount of Swap(my understanding was that is was unadvisable to make swap larger than that for Slackware). I have never actually run out of swap, but it seems the possibility definitely exists. One reason I want to switch to Linux, is so I can keep my computer(s) turned on indefinitely, without having to reboot constantly (like I had to with Win9x). It just seems like if I ran my computer for just a few days, it would run out of Swap, and I was interested if there was a way to "flush" it (or RAM), so I don't have to reboot. Perhaps I misunderstand the technology, my understanding is that when RAM is full, it stays that way, and processes start getting sent to Swap, and when that is full you are SOL. Is that correct? Or is the kernel more dynamic than that? I ask because after just a few hours of using Linux, my RAM is full and swap starts getting used. Is that normal?

Last edited by blnkgcrsr001; 04-27-2006 at 06:38 PM.
 
Old 04-27-2006, 08:14 PM   #7
zytsef
Member
 
Registered: Apr 2006
Location: Vancouver, Canada
Distribution: Slackware, Ubuntu
Posts: 168

Rep: Reputation: 30
Actually RAM should be fairly empty unless you're actually doing something with your computer. If you've ever paid for an operating system that doesn't collect things out of memory that aren't getting used I recommend demanding your money back. I suppose if you're running a web server with steadily increasing traffic you could see memory load increase the way you describe, but if it's just idling for a few hours then it shouldn't happen at all. Sounds to me like something is wrong.
 
Old 04-27-2006, 09:49 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, Linux caches everything it can into RAM, so RAM is usually NEARLY full, even on a quiet system. It always leaves a bit free at any instance (see top).
However, swap should never fill up entirely, that would indicate a memory leak in a program.
I've never heard of RAM defrag and frankly I'd trust the kernel boys to handle that whole area better.
 
Old 04-27-2006, 10:46 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
chrism01 is basically correct - blnkgcrsr001 try the following from a terminal
Code:
free > stats.log ; vmstat 1800 4 >> stats.log &
(including the trailing ampersand). This will run a background task to collect some stats - in this case every 30 mins for a couple of hours. The "jobs" command will show it running - when it no longer shows up, check the stats.log to see if it looks like a leak. Post it here for us to offer an opinion if you like.
 
Old 04-27-2006, 11:19 PM   #10
blnkgcrsr001
Newbie
 
Registered: Mar 2006
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00
chrism01 is basically correct - blnkgcrsr001 try the following from a terminal
Code:
free > stats.log ; vmstat 1800 4 >> stats.log &
(including the trailing ampersand). This will run a background task to collect some stats - in this case every 30 mins for a couple of hours. The "jobs" command will show it running - when it no longer shows up, check the stats.log to see if it looks like a leak. Post it here for us to offer an opinion if you like.
I tend to agree with that too. I'll give it a shot, and if it looks strange, I'll post it. Perhaps, my question is better asked this way: Is it possible to run a linux computer for several days or weeks without rebooting to free memory(doing normal user stuff like internet, email, watching movies, etc.)?
 
Old 04-27-2006, 11:50 PM   #11
zytsef
Member
 
Registered: Apr 2006
Location: Vancouver, Canada
Distribution: Slackware, Ubuntu
Posts: 168

Rep: Reputation: 30
Quote:
Originally Posted by blnkgcrsr001
Is it possible to run a linux computer for several days or weeks without rebooting to free memory(doing normal user stuff like internet, email, watching movies, etc.)?
Absolutely. My desktop has been up for over 5 days now.
 
Old 04-28-2006, 12:24 AM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
That's one of the things Linux is known for ie being able to do that. Remember people use it for servers that stay up for mths even yrs at a time.
If you're worried, perhaps you have some dodgy sw, but Linux itself should be fine.
Just check top regularly until you feel happy.
Don't forget a rogue prog could fill the non-swap part of your disk(s)... so run df regularly as well.
 
Old 04-28-2006, 01:55 AM   #13
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Astute observers who examine the Netcraft web site URL will note that all 50 servers in the Netcraft uptime list are running a form of BSD, mostly BSD/OS. None of them are running Windows, and none of them are running Linux. The longest uptime in the top 50 is 1,768 consecutive days, or almost 5 years.
OK, it's BSD instead of linux, but it gives an idea

Source
When you read a little further,
Quote:
Given the 497-rollover quirk, it is difficult to compare Linux uptimes vs. Windows uptimes from publicly available Netcraft data. Two data points are statistically insignificant, but they are somewhat telling, given that one of them concerns the Microsoft website. As of September 2004, the average uptime of the Windows web servers that run Microsoft's own web site (www.microsoft.com) is roughly 59 days. The maximum uptime for Windows Server 2003 at the same site is 111 days, and the minimum is 5 days. Compare this to www.linux.com (a sample site that runs on Linux), which has had both an average and maximum uptime of 348 days. Since the average uptime is exactly equal to the maximum uptime, either these servers reached 497 days of uptime and reset to zero 348 days ago, or these servers were first put on-line or rebooted 348 days ago.
 
  


Reply

Tags
oom, ram, swap



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
RAM: Does linux require as much ram as Windows XP? hanzj Linux - Newbie 48 04-18-2007 12:14 AM
Linux And Windows RAM Question tylerjroach Linux - Newbie 3 12-30-2005 09:42 AM
Win98SE Pentium166MMX/64MB RAM vs Linux AthlonXP+ 3000/512MB RAM : Lucent LT WinModem t3gah Linux - Software 2 04-22-2005 01:01 PM
linux ram question drrnsk8ter4 Linux - Software 1 04-25-2004 07:43 PM
Linux 7.3 RAM Question hitaz Programming 2 07-14-2003 03:50 AM

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

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