Re: Overcomittable memory

From: Jamie Lokier (lk@tantalophile.demon.co.uk)
Date: Fri Mar 17 2000 - 10:33:09 EST


Andreas Bombe wrote:
> Allocated and touched.
>
> int i;
> char *ptr = malloc(1024);
> if (!ptr) thats_tough();
> for (i = 0; i < 1024; i++) ptr[i] = 0;
>
> Only then you can be sure that this memory is there, because malloc
> gave you a pointer and the for loop didn't get you killed. This works
> because we sabotage COW through this, forcing a copy of the global COW
> zero page[1] if the malloc returns newly allocated pages (and doesn't
> reuse existing ones, in which case memory is there already). And you
> should also touch your stack, while you're at it.

Even this doesn't work if you've got duplicate page merging switched on
:-)

have a nice day,
-- Jamie

-
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:23 EST