Process getting killed when crossing memory limits

Hi,

I am new to LXD and trying to play with it. I have set limits.memory = 100MB and run a malloc program to consume all memory. I was trying to see what error I will get when accessing memory more than limit.

My process getting killed but I don’t see any error thrown.
Is it default behaviour ?/

That’s the normal Linux kernel behavior, yes.
Linux in general doesn’t throw memory errors on allocation, either you get the memory (sometimes after a delay) or you get killed by the out of memory killer.

This Linux kernel behaviour is adjusted through vm.overcommit_memory.
The issue is that this is a global change, so it affects the rest of the system as well.
More at https://www.kernel.org/doc/Documentation/vm/overcommit-accounting

Thank you for your support.