You can trivially alter the kernel not to check for memory availability,
but then the program will obviously only run on your hacked kernel (or on
machines with enough mem+swap). If you want to take this approach, just
uncomment tha calls to "vm_enough_memory(pages)" that exist in
linux/mm/mmap.c (it's used in both sys_brk() and do_mmap(), you can
delete both or just the one that is bothering you).
> 2 To trow away data (copying gc...) I should do mmap with /dev/null,
> right? (or was it /dev/zero)
You can use /dev/null, or alternatively an "anonymous" mapping with a
"fd" of -1, and the MAP_ANONYMOUS flag set. That way you don't need the
open/close stuff at all..
> I remember that a while ago there was a thread on usenet about "malloc
> lies in Linux". It was then said that mallocing 1GB was ok, so long as you
> didn't use the memory. Has policy changed or is mmap(rwx) so different?
It has never been true that you can malloc() as much as you want,
although some people have claimed it to be so. However, mmap() didn't use
to check at all, and that did change with 2.0.
Even now the checks are more "heuristics" than real checks that you can
depend on making sure you don't run out of memory. You can fool the
heuristics if you know what you're doing.
Linus