Re: Out Of Memory in v. 2.1

Florian Weimer (fw@cygnus.stuttgart.netsurf.de)
04 Oct 1998 09:21:38 +0200


Matthew Hawkins <matt@mail.goldweb.com.au> writes:

> > if( malloc(2048) == 0)

> Somebody slap me if I'm missing something obvious, but shouldn't this have
> absolutely no effect on the system whatsoever until the allocated memory is
> written to? Was the copy-on-write protection taken out of the kernel?

malloc() only requests large memory chunks (beyound 128K, I suppose)
directly from the kernel, and smaller memory requests are combined to
bigger ones. In order to do that, malloc() writes some data
structures into the memory it got from the kernel und thus triggers
copy-on-write. (I think `2048' was chosen because malloc() touches
each 4K page this way.)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/