lkml.org 
[lkml]   [1997]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Memory overcommitting (was Re: http://www.redhat.com/redhat/)
From
Date
Tuukka Toivonen <tuukkat@stekt.oulu.fi> writes:

> As I have understand, Linux returns ALWAYS success when using malloc(),
> because only reason why malloc() would fail, is memory overrun, and this
> will never happen in malloc().

That's wrong. Linux (since 2.0.x, 1.2.x didn't) uses a simple heuristic
to find out if enough memory is available. The other possibility is when
you run into your rlimits.

I really wish people would check the facts before posting.

overcom.c:
#include <stdlib.h>
main()
{
void *p;
p = malloc(1024 * 1024 * 1024); /* allocate 1GB */
printf("p = %p\n", p);
}

% ulimit -v
(unlimited)
% gcc -o overcom overcom.c
% ./overcom
(nil)
%

-Andi

\
 
 \ /
  Last update: 2005-03-22 13:39    [from the cache]
©2003-2011 Jasper Spaans