Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 02 Jun 2018 19:25:31 -0400
From:      Brennan Vincent <brennan@umanwizard.com>
To:        John Howie <john@thehowies.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Is it normal that a user can take down the whole system by using too much memory?
Message-ID:  <1527981931.2670335.1394316280.09410FC9@webmail.messagingengine.com>
In-Reply-To: <01EE7EEA-03AC-4D71-BA08-B0CEA97EE720@thehowies.com>
References:  <1527977770.2651378.1394286400.0806CC5C@webmail.messagingengine.com> <01EE7EEA-03AC-4D71-BA08-B0CEA97EE720@thehowies.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks John for the response -- this should help me solve my practical need=
s.

I'm also curious, however, to learn more from an OS design perspective. Why=
 isn't it possible for the kernel to realize it should kill `eatmem` rather=
 than make the system unusable?

Is this a hard problem in general, or just a missing feature in FreeBSD spe=
cifically ?

On Sat, Jun 2, 2018, at 6:40 PM, John Howie wrote:
> Hi Brennan,
>=20
> Do =E2=80=98man -k limit=E2=80=99 for details of means to restrict resour=
ce consumption.=20
> In particular, check out limits(1) and rctl(8).
>=20
> Variations of this problem have been around forever. An oldie but goldie =
is:
>=20
> main () { while (1) { fork (); } }
>=20
> I cannot say why you are getting the results you see on your specific=20
> system. I would check limits to see where they are set, and tweak them.
>=20
> Cheers,
>=20
> John
>=20
>=20
>=20
>=20
> Sent from my iPhone
>=20
> > On Jun 2, 2018, at 15:20, Brennan Vincent <brennan@umanwizard.com> wrot=
e:
> >=20
> > The attached program `eatmem.c` is a simple example to waste N gigs of =
memory as quickly as possible.
> >=20
> > When I run something like `eatmem 32` (on a system with less than 32GB =
of RAM), about half the time everything works fine: the system quickly runs=
 out of RAM and swap, the kernel kills `eatmem`, and everything recovers. H=
owever, the other half of the time, the system becomes completely unusable:=
 my ssh session is killed, important processes like `init` and `getty` are =
killed, and it's impossible to even log into the system (the local terminal=
 is unresponsive, and I can't ssh in because sshd is killed immediately whe=
never it tries to run). The only way to recover is by rebooting.
> >=20
> > Is this expected behavior?
> >=20
> > My system details are as follows:
> > FreeBSD 12 CURRENT x86_64 guest on VMWare Fusion.
> > ram: 8 GB
> > swap: 1 GB
> > Host: macbook pro running macOS.
> > <eatmem.c>
> > _______________________________________________
> > freebsd-questions@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd=
.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1527981931.2670335.1394316280.09410FC9>