Re: [2.4.26] overcommit_memory documentation clarification
From: Vincent Lefevre
Date: Sat May 08 2004 - 21:21:47 EST
On 2004-05-08 22:04:30 -0400, Richard B. Johnson wrote:
> What made you think that malloc would return 0 if the system
> was "out of memory??" Malloc will return NULL, which is not 0 BTW,
> if you are out of address-space or have corrupted it by writing
> past a previous allocation. Malloc's return value is a void *. It
> should be compared against NULL, not zero.
You are wrong. They are the same value (this is required by the ISO C
standard), i.e. both NULL == (void *) 0 and NULL == 0 must be true.
> When malloc() needs new "memory". It just asks the kernel to
> set the new break address or, in the case of mmap() mallocs, asks
> to extend a mapped region. Until somebody actually uses those
> regions, you haven't used any memory. So there is no way for
> malloc() to "know" ahead of time.
Again, you are wrong. The goal of malloc is to reserve memory.
This can be seen as used memory. If the implementation behaves
differently, then it is broken.
> If you run a malloc() bomb from the root account you should
> end up killing off a lot of processes. If you run it from
> a normal user account, and you have set the user's resource
> quotas properly, only the user should get into trouble.
The quotas are set properly (i.e. there are no quotas).
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17,
Championnat International des Jeux Mathématiques et Logiques, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/