#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char *try; size_t i;
for(i=1024;;i*=2) {
try=malloc(i);
if(try==NULL) {
printf("Maxed out around %d\n", i);
break;
}
memset(try, 0, i);
free(try);
printf("Succeeded with %d\n", i);
}
return 0;
}
Compiled with gcc 2.7.2.2 (fortran-patched), libc 5.3.12 on
kernel 2.0.27, machine with 24MB hard and 32MB swap memory. (486DX/33MHz).
IDE disk.
**RUN BY UNPRIVILEGED USER**, ulimit is at 2GB vm.
A single instance poops out, as expected, after 32MB. No problems.
Fine.
Then run three simulaneously:
maxm &
maxm &
maxm &
from bash. System fairly idle at the time.
This succeeded in killing named, klogd, something from NFS, with
console messages about "No memory for blah-blah". Then the bash
instance was killed, without comment. The kernel didn't panic,
but these daemons were gone.
Hmm, a user process can kill off daemons belonging to root.
Is this to be expected? (Answer: Better not be...) Is this a bug
in the memory management system? (Looks that way.)
Comments?
Thanks,
Dave
-- "A cloud of critics, of compilers, of commentators, darkened the face of learning, and the decline of genius was soon followed by the corruption of taste." -- GIBBON