1

This question already has an answer here:

I'm running a Ubuntu VM with an 8 GB RAM with docker containers ( 8 GB is just about enough for my requirements) but at some point the VM freezes/crashes due to memory exhaustion leaving me no choice but to power-off/reset the VM.

Is there a system configuration that can be done/added so that there is always enough just about enough memory for the OS to run without freezing?

marked as duplicate by Julie Pelletier, DarkHeart, meuh, Archemar, Rui F Ribeiro Apr 29 '17 at 22:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The OS never crashes because it runs out of memory when it has enough to operate normally. The worst that can happen, which could be your case, is that a program has a memory leak which fills the whole memory. The program in question would usually crash when the swap gets filled. – Julie Pelletier Apr 28 '17 at 13:43
  • It seems like there ought to be a program that can monitor ram & kill things in a set priority... maybe there already is somewhere – Xen2050 Apr 28 '17 at 14:24
0

You need, inside your VM's OS :

  • to adapt config settings of everything you run to ensure they use the minimum memory... (this depends on each services/programs)

  • You probably also need to use the correct settings for its "OOM Killer" (OOM being here Out Of Memory), ie the kernel part that will kill processes (sometimes not the right one!) depending on some heuristics. See for example : How the OOM killer decides which process to kill first?

  • and giving it also the option to swap memory when needed (and ajusting it also the "right way") will help (and should be used by your VM's OS before opting for the OOM "last resort" "solution")

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