malloc does not return null when out of memory

Gabor gabor at vmunix.com
Thu Jul 24 12:09:29 PDT 2003


On Thu, Jul 24, 2003 at 02:13:26PM -0400, Barney Wolff wrote:
# On Thu, Jul 24, 2003 at 02:01:06PM -0400, Gabor wrote:
# > ...
# > Here is another test.  This box has swap and I get a null pointer even
# > though ulimit -a says memory unlimited.
# > ...
# > 5242 0x2801d000
# > 5243 0x0
# > No more mem
# > # ulimit -a
# > data(kbytes)         524288   <<<<<<<<<<<<<<<<<<<<<<<

Ah, I am a cone head!  I fired up four of my test procs and put in an
infinite while after they ran out of memory.  After starting the
fourth and it chugging away eating up swap, one of the other three got
killed off.  So at least I know it has nothing to do with the
NO_SWAPPING option.  It's still disconcerting to me.  I would much
prefer to get back a null pointer that just have the kernel randomly
pick a victim who's a high memory user.  It's like a starving guy
being given food and then being shot in the head when he reaches for
it.


More information about the freebsd-stable mailing list