Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
I haven't really used a swap partition/file in some time, since I have 32GB of RAM. The other day, I had a program go nuts and consume all of my RAM in seconds. I've set up another swap partition to at least slow down a program if it decides to eat all of my RAM again.
After I set up the swap partition, I've noticed the system seems to be ignoring it. I've tried with a swap partition, and a swap file. Everything seems fine, but the system won't use it.
"This consumes my RAM quickly, and the computer will stop responding before swap is used" How do you know that the issue is this if it stops?
Some programs will usually still use swap even if there is enough ram.
Guess you could create some more swap on a usb flash drive and use it as priority to see if the hard drive access is killing this deal. Swapoff the hard drive swap before you test.
Also, pop a ulimit on that program. (See man bash.)
Don't allow it to run amok, especially if you suspect that the behavior is being caused by a bug of some kind. Once the limit is reached, attempts to allocate more memory will start to be denied.
Edit: Looks like it does work. Even with swappiness at 100, I still had to push the RAM to less than 1GB before swap kicked in.
Well sure, why would it use it before then?
RAM is used for basically two things:
1) Memory for running programs
2) Disk cache for commonly-accessed files
swappiness controls how aggressively the system will dump #1 to swap to clear up room for more of #2. However, if you haven't cached enough of your disk to even fill up your available RAM (1+2 < RAM), then why would it put anything on swap? You need to use enough disk cache to fill up your RAM with #2 before the system will even consider dumping #1 to swap, it won't do it before then because there would be no point.
Also, pop a ulimit on that program. (See man bash.)
Don't allow it to run amok, especially if you suspect that the behavior is being caused by a bug of some kind. Once the limit is reached, attempts to allocate more memory will start to be denied.
Thanks. I'll look into it. Last time something like this happened to me, I had made the mistake of having unlimited scrollback in Konsole, and had a looped script error out. I wasn't expecting convert (imagemagick) to go nuts creating a gif.
Quote:
Originally Posted by suicidaleggroll
Well sure, why would it use it before then?
RAM is used for basically two things:
1) Memory for running programs
2) Disk cache for commonly-accessed files
swappiness controls how aggressively the system will dump #1 to swap to clear up room for more of #2. However, if you haven't cached enough of your disk to even fill up your available RAM (1+2 < RAM), then why would it put anything on swap? You need to use enough disk cache to fill up your RAM with #2 before the system will even consider dumping #1 to swap, it won't do it before then because there would be no point.
I was under the impression that a swappiness value of 100 would prefer swap pretty quickly, even if swap was not needed. I was surprised that my system still froze before swap was used. In the past, when a program went nuts and X had stopped responding, I was able to login via ssh, and kill the offending app.
I was under the impression that a swappiness value of 100 would prefer swap pretty quickly, even if swap was not needed.
Needed for what. It won't stick a program into swap if nothing can make use of that RAM, it wouldn't make sense. What would be the point? If the RAM isn't needed for anything else, including disk cache, then there's no reason for the system to start throwing programs into swap. Now once your disk cache fills up the remainder of your RAM and the system has to make a decision between throwing away older disk cache versus throwing a running program into swap to make room for new disk cache, THAT'S when swappiness comes into play. A low value will keep your programs in RAM and throw away old disk cache to make room for new. A high value will throw unused programs into swap to make the room.
swappiness has nothing to do with an out of control program gobbling up all of your RAM.
Quote:
Originally Posted by replica9000
I was surprised that my system still froze before swap was used. In the past, when a program went nuts and X had stopped responding, I was able to login via ssh, and kill the offending app.
That is odd. Maybe it wasn't actually frozen? Maybe it was just busy trying to offload programs to swap as fast as possible to prevent an OOM condition? Sometimes a system can appear to "hang" for minutes while this is happening, but if you give it time usually it'll finally get enough data into swap that you can start to get a response out of it, and you can kill the offending process.
I think what threw me off, was that in the past, a small amount of swap was used (<100mib) even with all of the free RAM available. This time around, after a few days, swap usage was still at 0. I was starting to think that my storage setup was to blame. Seems to work fine.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.