As I understand it, setting /proc/sys/vm/overcommit_memory to 1 is supposed to make sure malloc always succeeds, and set the OOM killer loose if there's an actual memory problem.

I'm wondering what happens when you've malloc'd so much memory that you've exhausted the address space for your process? Does it return NULL despite the overcommit_memory setting, or does your process get a signal? Or something else entirely?

link|improve this question
feedback

1 Answer

up vote 0 down vote accepted

Malloc should return NULL and set errno if data segment runs out (even with overcommit enabled).

See manual for system call brk(2). Malloc calls brk to extend data segment. brk fails and sets errno to ENOMEM if extending the segment fails for any reason.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.