malloc() an indian giver?

Applied Magnetics 3003jalp at ucsbuxa.ucsb.edu
Tue Nov 27 04:03:58 AEST 1990


This thread originated in comp.unix.aix and turned out to be a BSD/SysV
issue.

I always thought that if malloc() returned a non-NULL pointer, you
could safely go ahead and use it.  If for any reason the memory request
can't be granted, malloc() returns NULL.

It appears that on SysV unixes, the sbrk() system call expands the
address space of the calling process __without checking that enough
swap space exists to back it up__.  Consequently, malloc() will happily
allocate virtual memory beyond the capacity of the machine; if the
process tries to use it all, the machine runs out of swap space and
some (innocent) process must die.  This is supposedly a feature to
allow sparse use of a large address space.

My questions are:
  1) Is this for real?
  2) If I ask for memory, I mean it.  What do I do, O net?

--Pierre Asselin, R&D, Applied Magnetics Corp.



More information about the Comp.unix.programmer mailing list