[Lxc-users] handle memory limits

Daniel Lezcano daniel.lezcano at free.fr
Mon Aug 15 22:21:05 UTC 2011


On 08/12/2011 11:00 PM, sfrazt wrote:
> Hi,
>
> i want to to have a application container that acts with memory limits
> as there is simple no more memory. Means: if it reaches the limit the
> next question for more memory should simple be denied.
>
> The default behaviour is to kill the application when it reaches the
> limit (not good).
>
> Then i found out that the config line
> 	lxc.cgroup.memory.oom_control = 1
> turn off the killing, but simple freezes the application. You have the
> possibility to get be notified if that happens, but then you could only
> kill the application manually or increase the memory limits and the
> application runs again. But this is also not that what i want.
>
> The application should simple behave as there is no more memory, so the
> application decides what to do if it gets no more memory.
>
>
> I hope somebody has a solution. Thx in advance for answer.

I think when an application in a host reach its *virtual* memory limits,
the allocation fails. But if the application is trying to get more
memory and there is not enough *physical* memory to do handle this
virtual memory (including swap) then it is killed by the oom killer. 
The behavior of the application is not changed regarding what would have
occurred on the host.

The memory cgroup acts for the physical memory. If you want your
application to fails to allocate memory rather than being killed or
frozen, you have to reduce its limits via the ulimit (which does not
really make sense).

If don't have enough memory on your container, you have to add more RAM
:) by increasing the cgroup memory value.





More information about the lxc-users mailing list