lkml.org 
[lkml]   [2000]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Overcommitable memory??
Date
In article <linux.kernel.fr1ddskpd1mnfr9gvjmnm8op9237gq61pd@4ax.com>,
James Sutherland <jas88@cam.ac.uk> wrote:

>Unfortunately, this would break a lot of code which would depend on
>the current (perfectly reasonable) implementation of malloc() and
>stack space - namely, memory is only allocated when you use it.

No, it wouldn't -- that code come pre-broken for your sysadminning
dispair.

>If you really want your code to occupy unused space, just touch the
>space when you allocate it. End of problem.

Unless, of course, you want to do something other than have some
random process die when you run out of memory.

given

char *foo = malloc(GIGABYTE(1));

it's a lot easier to check to see if that memory is there by doing

if (foo == 0) {
/* our out of memory processing */
}

than to do the suggested

long q;

for (q = 0; q < GIGABYTE(1); q += magic_number_to_dirty_pages)
foo[q] = 0;

/* if we get here, the malloc worked. If we're really lucky,
enough of the system survived the memory allocation so that
we can continue. */

or the slower

memset(foo, 0, GIGABYTE(1));

/* if we get here, the malloc worked. If we're really lucky,
enough of the system survived the memory allocation so that
we can continue. */

methods for really and truly allocating memory.

____
david parsons \bi/ Every time I think about overcommit, it gets ickier.
\/

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