lkml.org 
[lkml]   [2000]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Overcommitable memory??
Den 20-Mar-00 21:13:52 skrev James Sutherland følgende om "Re: Overcommitable memory??":
> On 20 Mar 2000 16:24:39 +0100, you wrote:

>>Den 20-Mar-00 13:39:26 skrev James Sutherland følgende om "Re:
>>Overcommitable memory??":

>>> If your app takes all the available memory, it should be blatantly
>>> obvious that you have done something wrong.
>>
>> Not in any way. The application can't read the kernel's mind. The system
>>has x MB of RAM+swap, the application asks for x+20 MB, the kernel says
>>"OK". How is the application supposed to know that the kernel is telling a
>>blatant lie? If you can't trust the kernel, your system is fsck'ed.

> The kernel doesn't do that anyway (unless you have explicitly disabled
> sanity checking). With or without normal overcommit, the behaviour
> here is identical; the only difference is in whether or not you really
> populate the whole block of address space you requested BEFORE you use
> it.

I'll just prove to you again that Linux overcommits:

telnet://rask@carlsberg/home/rask> cat memeater2.c
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
unsigned int i, n = 0;
void *mem[20];

if (argc < 2)
return (EXIT_FAILURE);

for (i = 0; i < 20; i ++)
{
if ((mem[i] = malloc (atol (argv[1]) * 1024 * 1024)))
n ++;
}

printf ("Allocated %lu MB of memory.\n", n * atol (argv[1]));

for (i = 0; i < 20; i ++)
free (mem[i]);

return (EXIT_SUCCESS);
}
telnet://rask@carlsberg/home/rask> gcc -Wall memeater2.c -o memeater2
telnet://rask@carlsberg/home/rask> free
total used free shared buffers cached
Mem: 128216 124924 3292 35052 33924 50616
-/+ buffers/cache: 40384 87832
Swap: 130748 20300 110448
telnet://rask@carlsberg/home/rask> ./memeater2 64
Allocated 1280 MB of memory.
telnet://rask@carlsberg/home/rask> cat /proc/sys/vm/overcommit_memory
0
telnet://rask@carlsberg/home/rask> cat /proc/version
Linux version 2.2.14 (root@carlsberg.kampsax.dtu.dk) (gcc version 2.7.2.3) #1 SMP Wed Jan 19 19:55:32 CET 2000

The system has around 200 MB free. My program asks for 200MB + 1080 MB.
The kernel says "OK".

Regards,

/¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯T¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\
| Rask Ingemann Lambertsen | E-mail: mailto:rask@kampsax.dtu.dk |
| Please do NOT Cc: to me or the | WWW: http://www.gbar.dtu.dk/~c948374/ |
| mailing list. I am on the list.| "ThrustMe" on XPilot, ARCnet and IRC |
| Never underestimate the bandwidth of a CD-ROM flying through the lab. |


-
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:57    [W:0.414 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site