linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Abhijit Karmarkar <abhijitk@veritas.com>
To: linux-mm@kvack.org
Cc: Abhijit Karmarkar <abhijitk@veritas.com>
Subject: doing large malloc's, parallelly crashes the machine.
Date: Thu, 14 Feb 2002 21:03:16 +0530 (IST)	[thread overview]
Message-ID: <Pine.GSO.4.21.0202142010220.24956-100000@revati> (raw)

Hello Gurus,

would be glad if someone could explain this phenomenon.

here's a program (c++) that allocates ~1M of mem continiously (without
freeing it):
-------------
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char*argv[]) 
{
	int *p;

	while(1) {
		p = (int*) new int [1000000];
		for(int j=0; j < 1000000; j++) p[j]=j;
		sleep(1);
	}
}
-------------

If I try to run this program (as root), after sometime the program
terminates with a "Terminated" message. I think that's because, it tries
to eat away all the free/swap memory available, and finally after reaching
the limits, the kernel _kills_ it. 

IMO good behaviour, as prevents a user-space (buggy) application from
getting the whole system down.

BUT, if I try to run _multiple_ such programs (in background) the system
hangs... does not respond to keyboard and becomes un-interactable.

here's the script:
-------------
#!/bin/sh
i=0
# put 400 such buggy programs in background...
while [ $i -lt 400 ]; do 
	above_program &
        let i=$i+1
done
------------
it hangs after putting about 20 such processes in background.

Why does this happen? if the single buggy program is terminated
(correctly) by the OS, what goes wrong when i put them in background?

Moreover the whole expriement does not happen on a Solaris box (SunOS
5.7), i.e. the shell _is_ able to spawn so many buggy programs (which do
terminate), and still the box is accessible (does not hang)?

Is this a bug in linux VM subsystem... or i'am i doing something wrong?
Isn't the OOM killer not supposed to handle this? 

Can such kind of phenomenon be prevented by setting certain VM related
parameters? How does Solaris handle this??


Details of the setup:
----
kernel: linux-2.4.9-13 (RedHat 7.2 errata) [non SMP]
mem config: (of a normal working system, before staring the experiment)

[1] cat /proc/meminfo:
        total:    used:    free:  shared: buffers:  cached:
Mem:  261259264 86876160 174383104    73728 25280512 27410432
Swap: 271392768        0 271392768
MemTotal:       255136 kB
MemFree:        170296 kB
MemShared:          72 kB
Buffers:         24688 kB
Cached:          26768 kB
SwapCached:          0 kB
Active:          50604 kB
Inact_dirty:       924 kB
Inact_clean:         0 kB
Inact_target:    65532 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       255136 kB
LowFree:        170296 kB
SwapTotal:      265032 kB
SwapFree:       265032 kB

[2] vmstat -1
  procs                   memory    swap        io     system    cpu
r  b  w  swpd   free  buff cache  si  so   bi   bo   in cs us  sy id
0  0  0    0  170264 24704 26768   0   0  252  133  143 89  3   4 93
----
can give any other stat/info if something is missing out here.


thanks in advance,

regards,
-Abhijit.

Please Cc: me the reply, I am not subscribed to the list. 





--
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/

                 reply	other threads:[~2002-02-14 15:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.21.0202142010220.24956-100000@revati \
    --to=abhijitk@veritas.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox