Sun Jun 6 23:52:00 PDT 2010
By default, Linux follows an optimistic memory allocation strategy.
This means that when malloc() returns non-NULL there is no guarantee
that the memory really is available. This is a really bad bug. In case
it turns out that the system is out of memory, one or more processes
will be killed by the infamous OOM killer. In case Linux is employed
under circumstances where it would be less desirable to suddenly lose
some randomly picked processes, and moreover the kernel version is suf-
ficiently recent, one can switch off this overcommitting behavior using
a command like
# echo 2 > /proc/sys/vm/overcommit_memory
See also the kernel Documentation directory, files vm/overcommit-
accounting and sysctl/vm.txt.
Checking malloc()'s return value is always a good idea (or, not checking
is a bad idea, as is potential null pointer dereference). But default
behaviour may not be entirely what you expect.
Disabling overcommitting may sound nice, but is a far from ideal
solution... hence it's not the default.
On the other hand, out of memory (OOM) situations being caused by icecast
are very unlikely. Icecast is not a heavy application wrt memory.
And, if you encounter an OOM situation on a server running icecast, simply
abort()ing icecast is not likely to resolve the OOM situation, and other
measures need to be taken.
That's where the OOM killer comes in to kill the most likely culprit,
based on scoring, so it will probably kill another process to make room
for icecast's needs. But the OOM killer should work only as a reminder to
take preventive measures, like ulimit-ing buggy programs or users.
More information about the Icecast-dev