LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-29-2005, 10:25 AM   #1
SplicedPepper
LQ Newbie
 
Registered: May 2003
Posts: 2

Rep: Reputation: 0
Force progams to stay in RAM


Is there a way to force linux to keep certain programs in RAM instead of letting the OS put them into swap file?

Its just two programs that need this done: srcds_l (DoD:Source Dedicated Server) and cod_lnxded (Call of duty Dedicated server, the only reason that this is needed is that theres ftp and http servers on the same box, and overtime ram seems to get eaten by these and not released, which forces the Dedicated servers into swap. This is on a 1gig system btw.

Debian 3.1

Latest Steam / Latest CoD
Apache/2.0.54
ProFTPD 1.2.10 Server

Last edited by SplicedPepper; 09-29-2005 at 10:41 AM.
 
Old 09-30-2005, 02:50 AM   #2
fenderman11111
Member
 
Registered: Jun 2004
Location: Denton
Distribution: debian, freebsd
Posts: 121

Rep: Reputation: 15
2 things you can possibly do:

1: there is a file salled /proc/sys/vm/swappiness

this file holds a number from 0 - 100, and it dictates how apt Linux is to use swap. (0 meaning not to spap, and 100 meaning to swap alot of stuff). do :

echo 0 > /proc/sys/vm/swappiness

as root, and that should help a lot. to have it set to 0 on every reboot, add this line:

vm/swappiness=0

to the file /etc/sysctl.conf


Also If you ahve enough ram, you can turn off the swap partition altogether (with fluxbox/gaim/galeon/gnome-settings-daemon/multiple gnome-terminals/vmware, i have never exceeded ~300 MB being used, and that's even with Windows running under vmware!)

to turn off a swap partition:

swapoff -a

to turn it back on:

swapon -a


---

hope this helps

-Brandon
 
Old 09-30-2005, 04:00 AM   #3
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
the short answer is NO. You never know what is in physical RAM anyway and you certainly can't and don't want to controll it. It's all managed by the CPUs MMU. The memory stats you get from Linux are just Virtual imaginary memory. Imaginry pages mapped to or pointing to things on disk the CPU thinks it might need. Thats about it plus some data structures like arrays that oint to the pages that point to the things on the disk.
the way the virtual memory works in the 2.6 series kernels is quite good and you shouldn't mess with it.
i think it's important to understand that swap is not just extra RAM
swap is for data that is not backed by media. When non-code non-file non-disk backed data gets generated by a program it immediately goes into the swap que so it can get saved if the system comes under heavy memory preasure. The rest of everything including the executable code itself (the stuff that's really necessary for program execution) just gets tossed out. Ejected i guess is the correct term. So even if your think your system is not using swap the executable code is still not available and needs time (not alot of time) to be reloaded.
It's on the disk anyway so if it's needed later it just gets reread.
Things that haven't been used in a long time are the first to go.
you can run something that goes a little crazy or the server can come under alot of preasure and it looks like the swap stays all used up but all that happens is anonymous data has been saved.
anonymous data that would otherwise be lost and your server would crash. This data can be retrieved if it is needed or it might justt be some memory leak crap that is never needed again. That's all swap is.

All you get wgen you turn off swap is a server that hard crashes.
 
Old 09-30-2005, 08:37 AM   #4
ironwalker
Member
 
Registered: Feb 2003
Location: 1st hop-NYC/NewJersey shore,north....2nd hop-upstate....3rd hop-texas...4th hop-southdakota(sturgis)...5th hop-san diego.....6th hop-atlantic ocean! Final hop-resting in dreamland dreamwalking and meeting new people from past lives...gd' night.
Distribution: Siduction, the only way to do Debian Unstable
Posts: 506

Rep: Reputation: Disabled
Theres an option for this in the kernel...forgot exactly which option handles this so you have to skim through.
 
Old 09-30-2005, 08:45 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Quote:
Originally posted by ironwalker
Theres an option for this in the kernel...
Is that the way live-versions like Knoppix (which have no write access to the disk(s)) work?
 
Old 09-30-2005, 11:36 AM   #6
enyawix
Member
 
Registered: Sep 2003
Location: ky
Distribution: gentoo
Posts: 409

Rep: Reputation: 32
this is a easy one buy more ram and just turn swap off. most systems can run on 1gb of ram with no swap.
 
Old 09-30-2005, 10:42 PM   #7
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
i will try again in more simple terms
if you turn off swap you will get this
Code:
99 % cpu  kswapd
and your system will start thrashing the memory like crazy (executable code will get purged and read back in constantly) because RAM it is being forced to hold onto other things it doesn't need at all and therefore can't hold onto the executable code it does need . and it will run like totall crap that is if you are lucky and it doesn't hit the wall and freeze.

There is absolutely no valid reason to disable swap while running a Linux kernel designed to use swap.

Last edited by foo_bar_foo; 09-30-2005 at 10:49 PM.
 
Old 10-01-2005, 03:07 AM   #8
enyawix
Member
 
Registered: Sep 2003
Location: ky
Distribution: gentoo
Posts: 409

Rep: Reputation: 32
Chill man the bulk of what goes into ram on a system with 1gb or more of ram is disk cache. That is why I picked 1gb for what I am saying. I have months of up time gaming no swap on a 2gb system. Running 15k rpm drives I do not need all that disk cache. If you do not have 1gb of ram you need swap. You are almost correct in saying "There is absolutely no valid reason to disable swap while running a Linux kernel designed to use swap." I do not want to give up the disk space. Ram is much cheaper that 15k rpm SCSI disk space.

Last edited by enyawix; 10-01-2005 at 03:11 AM.
 
  


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
Where are my newly installed progams? behnt Linux - Newbie 9 04-16-2005 04:46 PM
force the RAM! alaios Linux - General 4 09-22-2004 05:33 PM
Installing progams in Suse 9.1 Professional sirtrack Linux - Newbie 3 06-20-2004 03:29 PM
Security Progams that work with a hardware router rufassa Linux - Security 7 12-18-2003 07:42 AM
Progams links gone after KDE update Coolrunr Mandriva 5 12-07-2003 10:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:07 PM.

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