Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!hub.ucsb.edu!ucsbuxa!3003jalp From: 3003jalp@ucsbuxa.ucsb.edu (Applied Magnetics) Newsgroups: comp.unix.programmer Subject: malloc() an indian giver? Message-ID: <7387@hub.ucsb.edu> Date: 26 Nov 90 17:03:58 GMT Sender: news@hub.ucsb.edu Distribution: comp Lines: 20 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.