lkml.org 
[lkml]   [1998]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Out Of Memory in v. 2.1
From
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.065 / U:1.880 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site