This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc question


On Mon, 2004-04-26 at 18:56 +0200, Sebastien Decugis wrote:

> The problem is that my process is killed when no memory is left. Is that
> a wanted behavior? The posix standard requires the function to return
> NULL and set errno to ENOMEM. Is this behavior dependent on my linux
> distribution (RH9)?

This is the intentional behavior of Linux.

malloc() does return ENOMEM upon memory failure.  Set your SIZEBLK to a
larger stride and you should see it.  You just do not see the error in
your case because the Linux kernel's Out Of Memory (OOM) killer killed
your process first.

> A last question: Does anybody knows a way to go near memory limit
> without being killed?

If your application has the CAP_SYS_RAWIO capability, it is sent SIGTERM
instead of SIGKILL.  So you can catch the SIGTERM and respond.

But the real answer is do not consume all of the memory in the system.

As Uli would say, this email is off-topic for this list, BTW.

	Robert Love



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]