Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Locking processes against being killed when low on memory

--- Stephen Borrill <> wrote:

> On Thu, 21 Feb 2008, Gary Thorpe wrote:
> > --- Stephen Borrill <> wrote:
> >
> >> I'm using NetBSD 4.0 with Xorg, etc. running from flash, i.e. no
> >> swap. As
> >> it's embedded, everything is running as root. Is there any way to
> tag
> >>
> >> processes as unkillable when running out of memory? Some processes
> >> (e.g.
> >> the X server, management daemon and session manager) need to
> remain
> >> running throughout. I don't mind if other things such as
> web-browsers
> >> get
> >> killed. Currently bad things happen when it starts to run out of
> >> RAM...
> >>
> >> --
> >> Stephen
> >
> > I don't think NetBSD has an "out-of-memory" killer (as in Linux?):
> I
> > think the application which causes the unserviceable page fault is
> just
> > killed. If I am not mistaken in this, you cannot predict beforehand
> > which applications will be targeted (this includes 'init') because
> any
> > of them may try to access over-committed memory. Maybe you could
> try
> > 'ulimit' to make sure the memory usage is contained? This may be
> > feasible for an embedded system (or maybe not).
> I'm interested to know what effect mlockall(2) may have on this. If
> we 
> have no swap at all, it should be possible to wire all important 
> processes. This may require altering the restriction of only allowing
> up 
> to a third of RAM to be wired though.
> -- 
> Stephen

The main drawback is that you would have to manually add calls to
mlockall() to your applications' source code and rebuild them (maybe
just stick it somewhere in the initialization code?). Perhaps it could
be added to an library (maybe even dynamically linked).

If there were a tool to specify that arbitrary running processes should
be locked in memory then that would probably solve the problem for an
embedded system.

      Get a sneak peak at messages with a handy reading pane with All new 
Yahoo! Mail:

Home | Main Index | Thread Index | Old Index