Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am able to compile a program with 1 GiB RAM on a VPS using old 2.6.x kernel. But when I tried to compile it on a VPS with 1.1 GiB RAM and 3.9.x kernel, the compiler always killed by OOM Killer.

How do I make OOM more passive?

share|improve this question
2  
Have you tried just turning the stupid thing off? –  voretaq7 Jul 10 '13 at 15:10
add comment

2 Answers

up vote 5 down vote accepted

You don't change the OOM killer - it's like that for a reason. but what you should do is reduce the memory overcommit. By default this is 50% (see /proc/sys/vm/overcommit_ratio) to handle the case where programs try to claim more memory than they ever need. But if you've got well-written programs which only claim the amount of memory they need (or you're runing JVMs which never do gc because they don't know the system is tight on memory) then the OOM Killer starts harvesting stuff.

share|improve this answer
    
btw, vm.overcommit_ratio is used iff vm.overcommit_memory == 2, but default value is 0: lxr.free-electrons.com/source/mm/mmap.c#L134 –  SaveTheRbtz Jul 11 '13 at 4:01
add comment

If you have enough space on your FS you can add temporary swap space to your VM via:

# fallocate -l 4g /SWAP
# mkswap /SWAP
# swapon /SWAP

But keep in mind that compilation won't be a fast process if your system is aggressively swapping.

share|improve this answer
    
Out of curiosity, why map /SWAP to a loopback device? Why not just mkswap /SWAP and swapon /SWAP? –  espenfjo Jul 11 '13 at 5:34
3  
losetup is useless. Just create an empty file and swapon to make it works. –  比尔盖子 Jul 11 '13 at 7:04
    
I'm just used to it because it has -e flag that I was using when swapping on external flash drive. Here, yes I guess it's rather useless. –  SaveTheRbtz Jul 12 '13 at 7:53
    
I don't like shouty paths. There's no need to make it shouty. –  Tom O'Connor Jul 12 '13 at 8:24
add comment

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.