0

On my Fedora laptop, I have deactivated the swap partition because it appears pretty useless to me. The system will come to a halt when it starts writing to the SSD. The applications that consume this much memory usually do not stop, so once they are allocating, they will allocate more and more (gitk with 1M line diffs, faulty program with memory leak, …).

Still I find the system writing to the SSD when memory runs out. It seems that there is no swap enabled:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           7,7G        2,2G        455M        685M        5,1G        4,8G
Swap:            0B          0B          0B

Where is the setting that I have to enable in order to let the kernel kill programs instead of swapping to the SSD?

  • 1
    To anyone reading this: if you are running a gitk version that was initially published prior to 18 Jan 2017, and are encountering RAM over-consumption, then this comment may be helpful to you. – sampablokuper Apr 2 '18 at 17:22
0

I think you’re looking for /proc/sys/vm/overcommit_memory, which you should set to 2 to enforce memory allocation checks (programs won’t be able to allocate more memory than is really available). You’ll probably need to adjust /proc/sys/vm/overcommit_ratio too, at least if any of your programs need to allocate more than half your installed memory. The procfs manpage documents all these.

I would recommend reconsidering your decision to disable all your swap; see Why does Linux need swap space in a VM? for details.

It’s worth noting that the kernel can’t swap out if swap is disabled. All it can do is used mapped files as backing store, but that typically doesn’t involve writing (in particular for executables and libraries). If you’re seeing writes under stress, it’s probably because the kernel is flushing dirty pages (its buffers mainly) to try to reclaim them.

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.