Re: Overcommitable memory??

From: David Whysong (dwhysong@physics.ucsb.edu)
Date: Fri Mar 17 2000 - 04:30:20 EST


On Fri, 17 Mar 2000, James Sutherland wrote:
>On Fri, 17 Mar 2000, David Whysong wrote:
>
>> So malloc() returns success when I ask for an 800 megabyte array on a
>> machine with only ~640 megabytes of free virtual memory.
>
>It's not supposed to do that, AIUI - malloc() will only succeed if either
>(a) overcommit_memory is enabled (which disables all sanity checking - you
>want 2Gb on a 4Mb 386? Here it is...) OR (b) the system stands a *chance*
>of successfully allocating it (i.e. it has the amount you requested free).

That's more or less what it does (see below). The problem is, what do you
mean by "free" memory? -- there are several ways to measure this, none of
which are all that useful.

>It doesn't ALLOCATE that memory to you immediately - but it is supposed to
>check that it could do, if needed. (So the source appears to indicate,
>anyway.)

I'm not looking at the kernel source (big mistake in this mailing list, I
know...), I'm looking at it from an app developer's point of view. From my
experiments, it seems that with /proc/sys/vm/overcommit_memory=0, malloc()
will succeed so long as you ask for less than the total RAM+swap on the
machine. If overcommit_memory=1 anything goes.

Dave

David Whysong dwhysong@physics.ucsb.edu
Astrophysics graduate student University of California, Santa Barbara
My public PGP keys are on my web page - http://www.physics.ucsb.edu/~dwhysong
DSS PGP Key 0x903F5BD6 : FE78 91FE 4508 106F 7C88 1706 B792 6995 903F 5BD6
D-H PGP key 0x5DAB0F91 : BC33 0F36 FCCD E72C 441F 663A 72ED 7FB7 5DAB 0F91

-
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/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:24 EST