Subject: Re: sbrk() semantics ....
To: Gordon Ross <>
From: Keith Moore <>
List: tech-kern
Date: 03/13/1995 10:25:34
> > [...]  But IMO _some_ mechanism should be exported for user-land to
> > get memory without the time and space overheads imposed by malloc().
> There is a way:  (at least for SunOS, NetBSD, SysVr4, ...)
> (The trick:  mmap /dev/zero with MAP_PRIVATE)

One nice thing about sbrk() is that it works very nearly everywhere.

Also, I'm wary of memory allocation schemes that don't actually
reserve memory (or backing store) for the pages allocated.  With
sbrk(), if the system doesn't have enough memory, you should get a
return value of -1.  But there's no way to do this if the error
occurs when some process happens to touch a new page. 

On AIX, memory allocation always appears to succeed.  Then when the
kernel runs out of memory, it guns some random nonessential the automounter, and all hell breaks loose.

Not sure if this is a problem for mmap (...MAP_PRIVATE...) or not, but
the comment "(You don't really get it until you touch it! 8^)" makes
me wonder...