Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been having this severe performance issue, both in Ubuntu 11.10, and Debian Wheezy:

If one process uses up a great deal of RAM (say, 3700 MB out of 3900 MB), the system quickly becomes unusable, with constant disk thrashing. It gets to the point where the window manager doesn't respond, and killing the offending process takes several minutes. (Actually getting to a terminal, issuing pkill, waiting a while longer until the signal actually gets through)

This problem occurs even if the swap partition is completely disabled.

Investigating with iotop, it looks like most of the disk activity is disk read, going to processes such as google chrome, and the X window renderer. However, this is only limited information, as iotop no longer updates while the system is in full-thrash mode.


My question is:

1) what is causing the massive disk read? 2) how can I prevent this from making the system unusable?

share|improve this question
    
Don't disable swap. That will force the system to keep all dirty pages in memory, making the problem much worse. Tell us more about your outer problem. Why is a process using so much memory? Is it because it's broken? Is it malicious? –  David Schwartz Mar 19 '12 at 19:14
    
I've run into the problem in a few different ways. sometimes opening up too many chrome tabs will trigger it, sometimes trying to cache 1M+ data structures in a python script will cause it. Running make with -j of 6 or 7 on something like the Boost libs will eat up memory pretty reliably, and then leave me thrashing. –  YenTheFirst Mar 19 '12 at 19:45

2 Answers 2

up vote 4 down vote accepted

The system is moving data in RAM in and out of the hard drive to make way for other data in RAM. Disk operations are far slower than RAM operations, causing the system to slow down significantly. When your system is running out of physical memory, the system does this to expand the amount of "virtual" memory available, at the cost of performance. This condition is called thrashing.

Unfortunately, the only full solution to this problem is to add more RAM. Memory modules are relatively inexpensive; if you are consistently reaching the limits of available physical memory, you should add memory to your computer.

Edit: Because your system is low on physical memory, programs need to read from the hard drive more often, because free space in RAM is normally used to store files frequently or recently accessed to reduce disk reading. With low free RAM, fewer files can be cached, reducing performance. This is especially the case with applications like Chrome, which is quite memory- and I/O-intensive. Once again, adding RAM will increase performance. For more information on caching, see the Wikipedia article.

share|improve this answer
    
The problem occurs even if I completely disable a swap partition. Also, I don't think simply more RAM will help, since the problem tends to occur with degenerate programs (some of which are written by me) using up arbitrary amounts of memory. –  YenTheFirst Mar 19 '12 at 18:47
    
Some system process may be blocking normal I/O operations in applications such as Chrome. In this case, it appears the OOM killer is attempting to kill processes using abnormal amounts of memory. –  DragonLord Mar 19 '12 at 18:51
    
I'm sorry, I don't quite understand this comment. The I/O isn't blocked - Chrome, and X, and other random processes, are doing a lot of disk reading. No processes are killed by the Out of Memory killer, since the memory's not actually full, just nearly full. If the OOM would at least kill the offending process, it wouldn't be so bad. –  YenTheFirst Mar 19 '12 at 18:59
1  
This answer most clearly describes what's going on, so I'm accepting it. Any ideas on 2)? Simply adding more RAM isn't always an option (especially if you've maxed out the RAM on a laptop). Low memory situations happen in life, how can Linux be made to not become unusable in those situations? i.e., if I've only got 200MB free, I don't care about rendering chrome, I just want to switch to a terminal and kill some processes. –  YenTheFirst Mar 19 '12 at 22:52
1  
You could use a USB flash drive and dedicate it to swap space. Buy a high-speed flash drive (at least 4 GB), create a swap partition on it, and activate it. The effect of this is similar to using Windows ReadyBoost on a Windows Vista or Windows 7 system. –  DragonLord Mar 20 '12 at 0:01

DragonLord is correct, the issue is the fact that the OS does not like that your using an excessive amount of RAM. The closer you are to maxing out your RAM. The system will fall into a state where it starts using virtual memory. The faster your harddrive the faster your computer will be when in this state, however there is only so much performance you can gain from that. More RAM is needed in order to stop this from happening.

Clearly you already realize the issue is only when using certain programs, some in which you have created. Due to the information that has been given it is only logical to assume your issue is RAM.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.