5

I've been running a process (gdb) that can easily use up all my ram and swap space. Every time that happens the whole system becomes very non-responsive and Xorg will barely update, I can't swith to another tty I can't type commands in the console etc.

I've tried to setting aside memory with:

sudo sysctl -w vm.min_free_kbytes=407580
sudo sysctl -w vm.swappiness=5

Some of the virtual memory was spared but the swap space was used up and then the system still became non-responsive.

Does anyone have any foolproof ways to prevent the system from freezing up completely? So that I can kill memory hogging processes?

Update:

I found a way to limit memory usage per process launched from a particular shell with:

ulimit -v 2037900

This caps each process to 2037900 KiB (Which is my total memory) of virtual memory. Which is more than any one process should use. So far this seems to prevent the system from slowing down and freezing.

I would still like to know if anyone knows of any good system resource management practices.

  • 1
    Buy N amount of memory where N >> M where M is the amount used by the system. This may make memory vendors happy, and your wallet sad. Moving the swap partition to a SSD drive might also help, similar story about the vendor and your wallet. – thrig Oct 17 '15 at 0:21
  • Fix the cause of the excessive memory usage. And monitor with something like nagios. OOM killer. – Ryan Babchishin Oct 19 '15 at 3:37
  • The problem I'm trying to fix is the system allowing a process to eat up all the memory and freeze the system (not the greedy process). It seems to me that OOM Killer should prevent this kind of thing from happening but it doesn't seem to kick in. – bobajeff Oct 19 '15 at 22:49
  • I'm having this problem right now on my Debian machine. I can't even open iotop to see what process is doing it. It seems like a terrible flaw that this happens, and it's happened in every distro I've used. – Erhannis Nov 11 '16 at 12:41
1

Look into the Linux Out Of Memory Killer. Doesn't it kick in automatically on your server? It has on mine.

http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html

  • 1
    In my experience, there's a long period (sometimes hours or days) between when memory pressure gets tight enough to make the computer unusable, and when memory actually runs out and triggers the OOM killer. – Mark Oct 18 '15 at 0:16
  • It's not a server but a desktop with Lubuntu 15.04. That sounds like that is something that should be triggered in my system but the process just eats up almost all available memory and swap but doesn't get killed. – bobajeff Oct 19 '15 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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