[systemd-devel] test program won't stop after hitting MemoryLimit
Lennart Poettering
lennart at poettering.net
Thu Feb 18 17:12:54 UTC 2016
On Thu, 18.02.16 07:05, Jeremy_Fang at dell.com (Jeremy_Fang at dell.com) wrote:
> Dell - Internal Use - Confidential
Really? You sent this to a public mailing list...
> Hi All:
>
> I am trying to test Resource Control of system by setting
> MemoryLimit on my Debian system. Unfortunately it won't work after
> my testing. Maybe I am not configuring right. Please let me know how
> to fix this.
Linux has an overcommiting memory manager. MemoryLimit= operates on
actual memory usage. With malloc() you only allocate address space
however. It basically just gives you an address range and the promise
that keep the memory around should you ever actually store something
in it. In your test program you never do that however, hence it will
never be backed by real memory.
Consider invoking memset() on the memory you allocate, so that it is
actually touched.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list