Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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!)
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.
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:
Theres an option for this in the kernel...forgot exactly which option handles this so you have to skim through.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.