Previous: , Up: Limiting memory usage   [Contents][Index]


5.3.3 OS usage limits

Many operating systems permit limiting a process’ memory usage by setting a usage limit; on most Unix-like systems, this is done with the -v option to the ulimit command. Typically, the effect is to cause calls to the malloc and mmap library functions to fail.

Polipo will usually react gracefully to failures to allocate memory14. Nonetheless, you should avoid using OS limits to limit Polipo’s memory usage: when it hits an OS limit, Polipo cannot allocate the memory needed to schedule recovery from the out-of-memory condition, and has no choice other than to drop a connection.

Unfortunately, some operating system kernels (notably certain Linux releases) fail to fail an allocation if no usage limit is given; instead, they either crash when memory is exhausted, or else start killing random processes with no advance warning15. On such systems, imposing an (unrealistically large) usage limit on Polipo is the safe thing to do.


Footnotes

(14)

There are exactly three places in the code where Polipo will give up and exit if out of memory; all three are extremely unlikely to happen in practice.

(15)

How I wish for a ‘SIGXMEM’ signal.