mmap and resource limits
Jilles Tjoelker
jilles at stack.nl
Fri Oct 12 22:15:44 UTC 2012
On Fri, Oct 12, 2012 at 01:38:28PM -0400, John Baldwin wrote:
> On Friday, October 12, 2012 12:04:19 pm Marcel Moolenaar wrote:
> > On Oct 8, 2012, at 10:40 AM, Marcel Moolenaar <marcel at xcllnt.net> wrote:
> > > What's the progress of mmap(2) doing resource accounting and
> > > it respecting resource limits?
> > *silence*
> > Ok, so no new progress. We're still not doing it and we don't
> > have an idea of how we want to do it if or when we're going to
> > want to do it. Consequently: we still need brk()/sbrk().
> > Correct assessment?
> Well. You can use RLIMIT_AS, but that includes anything you map, not
> just malloc().
This is effective for many applications. I have found it particularly
useful against runaway memory leaks in applications moved from 32-bit to
64-bit systems.
> The problem is that even if you use sbrk() and rely on RLIMIT_DATA,
> any misbehaving app can just use mmap(MAP_ANON) or shm_open() to get
> around that.
As of 8.0 it is possible to enable swap accounting to limit anonymous
memory. This uses the vm.overcommit sysctl and RLIMIT_SWAP rlimit
described in tuning(7). For example:
# sysctl vm.overcommit=2
$ ulimit -w 100000
The rlimit limits the total for the UID (much like RLIMIT_NPROC,
RLIMIT_SBSIZE and RLIMIT_NPTS).
--
Jilles Tjoelker
More information about the freebsd-arch
mailing list