[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

oom_killer - Does not perform when stress-tested (system hangs)



Hi,
I'm trying to run multiple instances of the following program which keeps
on allocating memory , assigns value if malloc was not NULL  and does not
free.
#include <stdlib.h>
int main()
{
   int *p,i;
   while (1)  {
      p = (int *) malloc(1000000 * sizeof(int));
      if(p!=NULL)
          for(i=0;i<1000000;i++)
             p[i]=i;
      sleep(1);
   }
}


When I run say about 5 instances, oom_killer kills one instance of my
program when SwapFree is 0K, goes on to kill each of the other instances in
turn. The machine is slow in response when my program was running but
perfectly usable after that.
When I run 25 or 40 instances, the system hangs. No response. After waiting
for more than 1.5 hours I did a manual reboot (hard-reset). I looked for
/var/log/messages for "Out of Memory: Killed process...", I could find
about 15 entries for the killing of my program's instances, none for others
and there were no entries for more than an hour till I hard-reset the
machine.
I used a PC with Linux -2.4.7-10 (RH 7.2). RAM:128 MB, Swap: 256 MB. I run
as an user and not as root.

Is this expected behavior? Is it the responsibility of the user not to
"fill" the memory? Could oom_killer not take care of such a stress-test?
Should any thing warn the user when swap-space is full?


Srikrishnan


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/