By looking at the graphs, I think he was not really running out of memory.
Instead, the Out Of Memory killer (OOM killer) decided somehow that some process had to die.
Let me quote Andries Brouwer:
Quote:
An aircraft company discovered that it was cheaper to fly its planes with less fuel on board. The planes would be lighter and use less fuel and money was saved. On rare occasions however the amount of fuel was insufficient, and the plane would crash. This problem was solved by the engineers of the company by the development of a special OOF (out-of-fuel) mechanism. In emergency cases a passenger was selected and thrown out of the plane. (When necessary, the procedure was repeated.) A large body of theory was developed and many publications were devoted to the problem of properly selecting the victim to be ejected. Should the victim be chosen at random? Or should one choose the heaviest person? Or the oldest? Should passengers pay in order not to be ejected, so that the victim would be the poorest on board? And if for example the heaviest person was chosen, should there be a special exception in case that was the pilot? Should first class passengers be exempted? Now that the OOF mechanism existed, it would be activated every now and then, and eject passengers even when there was no fuel shortage. The engineers are still studying precisely how this malfunction is caused.
Source:
https://lwn.net/Articles/104185/My suggestion to have more swap is
not for it to be actually used (which we all know it's a lot slower than real RAM),
it's just something that may help to keep the OOM killer away.
Try building a kernel without swap on a Linode 1024 and see what happens. With enough swap, it works.
Does somebody know how to "optimize" gcc? I for sure would not even know where to start.
Do I need a Linode 2048 to build the kernel? Surely not if I can use a Linode 1024 with 2G of swap.
You can reduce overcommiting in MySQL or Apache by "optimizing" them, but there is not a general recipe for optimizing everything.
BTW: What I do to avoid OOM killer myself (in addition to have plenty of swap, 1G or 2G), is to have a file called /etc/sysctl.d/10-no-overcommit.conf containing this:
Code:
vm.overcommit_ratio = 100
vm.overcommit_memory = 2
(enable with "sysctl --system").
Then I will worry whenever I see that the system runs slow, not whenever OOM killer randomly decides to kill a random process following some strange algorithm, as if they were passengers in a plane in the story by Brouwer.