Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g6CRN-0004L4-DJ for pgsql-general@arkaria.postgresql.org; Sat, 29 Sep 2018 10:25:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g6CRJ-000849-0U for pgsql-general@arkaria.postgresql.org; Sat, 29 Sep 2018 10:25:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g6CRI-00083z-KN for pgsql-general@lists.postgresql.org; Sat, 29 Sep 2018 10:25:32 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g6CR7-000172-6h for pgsql-general@lists.postgresql.org; Sat, 29 Sep 2018 10:25:30 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 8DDCF1FF0; Sat, 29 Sep 2018 12:25:18 +0200 (CEST) Date: Sat, 29 Sep 2018 12:25:18 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Out of Memory Message-ID: <20180929102518.rhz5o7wo3ner4zv6@hjp.at> References: <1537971881585-0.post@n3.nabble.com> <3321.1537972628@sss.pgh.pa.us> <1537973357976-0.post@n3.nabble.com> <1537979068444-0.post@n3.nabble.com> <1537979569920-0.post@n3.nabble.com> <824208787ca76bb05c1076b72629e394c6ed660b.camel@cybertec.at> <20180927063039.n5ea4xuefxtrbusa@squirrel.exwg.net> <3973cda30071755051a8b63a1aa64727a5a79998.camel@cybertec.at> <704B7535-D731-47EA-9E1E-2055B42CAD7B@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="m4y6tpd7neenbcxx" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --m4y6tpd7neenbcxx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-09-28 07:23:59 +0200, Laurenz Albe wrote: > Rob Sargent wrote: > > > Christoph Moench-Tegeder wrote: > > > > ## Laurenz Albe (laurenz.albe@cybertec.at): > > > >=20 > > > > > vm.overcommit_memory =3D 2 > > > > > vm_overcommit_ratio =3D 100 > > > > >=20 > > > > > Linux commits (swap * overcommit_ratio * RAM / 100), > > > >=20 > > > > ^ > > > > That should be a "+". > > >=20 > > > Yes; shame on me for careless typing, and thank you for the > > > correction. > >=20 > > Are there any parentheses needed in that formula? >=20 > No. It is swap space plus a certain percentage of RAM. >=20 > I don't know how the Linux developers came up with that > weird formula. I suspect they copied it from some other Unix. Traditionally, Unix allocated all memory in the swap space. You could say that the swap space was the "real memory" and RAM was a cache for that (Hence the rule that swap must be at least as large as RAM and should preferrably be 2 or 4 times the size of RAM). So, when Unixes started to allow allocating more virtual memory than swap space, they were "overcommitting".=20 But for Linux that doesn't make much sense, since a page lived either in RAM /or/ in swap right from the start, so the limit was always RAM+swap, not swap alone, and you are only overcommitting if you exceeded the size of the sum. The overcommitment in Linux is of a different kind: Linux uses copy on write whereever it can (e.g. when forking processes, but also when mallocing memory), and a CoW page may or may not be written in the future. It only needs additional space when it's actually written, so by counting the page only once (hoping that there will be enough space if and when that page is written) the kernel is overcommitting memory.=20 hp --=20 _ | Peter J. Holzer | we build much bigger, better disasters now |_|_) | | because we have much more sophisticated | | | hjp@hjp.at | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson --m4y6tpd7neenbcxx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAluvUwgACgkQ8g5IURL+ KF1lkg/+M7Tr28y/onqbd2cJux+4RKYaYbiAzfj883tx9rW2eWENevdXyv7wD/+r L8Kgu5rG+c99kp8FvTdKnTu+xlRgMskf9Jczo74n/0gNKASUHu0/FrYdkRo1Jtew m0S0EjneV+9iI2jn1h7v4shoM+TvcDTbfnKN9Z5iOlgPvFypyIQruSCd7j5eeFqv qUN3D+4V+RLyN0qrhp6Ra2T1a8YtC3JQx6vmhBq+49UnbG7GVRyn0utQCVQIZl3S YKOdlsocyzc3j1zQAWZ2PiVgMFoLOyDhnItMoEkKDYvOr4PdV0k48XZ67O+tGAib m1uoJcZFmOHgh4U/vqLLxZHhbcUyA3CF3pm4w+geL8wND/Gj88aGDJSJzBeIAcbC 5imywKhJ78e+jVDf2dsx7rBXMtd6vZ8Zmu8r/nIPx5b60oY5vQYdPhcxBAMtmead j5csHGKkmTmS5zhYYcJs7VTOicSK8bvwMMGc1QRccjcmsHAOb0b/kEi+s7bsglGE bBFrDCuErerZrj5dmP0726lWzcXxmSL4UFyGwfaCTAi4Sbd7VS3/b7VcdQ1O0Bue S1ctxO1121jw5zlJwqZrhIKzxLcWpuys914HUrysFxVjnrH0D23Xef9Da213uqKq A7hrNPMbydlKSwG65Eg1sAz8rITlREGf8Q6rUzrZFiOZaLHrpM8= =vzXz -----END PGP SIGNATURE----- --m4y6tpd7neenbcxx--