Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIxgY-0001V9-Mn for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 17:27:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIxgX-0000TA-G2 for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 17:27:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIxgX-0000Sv-8L for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 17:27:05 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIxgT-0005LR-Ia for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 17:27:04 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 45FB6395E; Thu, 17 Sep 2020 19:26:59 +0200 (CEST) Date: Thu, 17 Sep 2020 19:26:59 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL processes use large amount of private memory on Windows Message-ID: <20200917172659.GA417@hjp.at> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --9amGYk9869ThD9tj Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-09-17 11:19:07 +0200, =D8ystein Kolsrud wrote: > I have a product that uses PostgreSQL (v9.6) as database on Windows, and = we > often observe that the "shared working set" memory reported for the indiv= idual > connection processes is quite high (around 200MB), but the "private worki= ng > set" is relatively low (around 5 MB). I assume this is due to the process= es > utilizing the shared buffers of Postgres, and in these cases everything w= orks > fine as the total memory consumption on the system is quite low. But for = some > deployments we have observed that the "private working set" is around 200= MB as > well, and in these cases the server quickly runs out of memory when the n= umber > of connections rises. I have never been able to reproduce this behavior m= yself. [...] > All settings typically referred to (like "work_mem" and "temp_buffers") a= re at > default settings, and I have a very hard time seeing how those settings c= ould > add up to memory in the magnitude of 200MB. The work_mem setting is per operation (e.g. sort, hash join, etc.), so a complex query may use a multiple of it. However, the default is just 4 MB, so a query would have to be very complex to use 50 times as much. Also, that memory is freed after the query (however "freed" does not necessarily mean "returned to the OS", it can just mean "marked as availiable for reuse" - that depends on the C library and the OS). What I would do: * Set log_statement to all (warning: that can be a lot of log messages. It can also be a privacy/security hazard, depending on who has access to the server and how sensitive queries are). * Frequently (at least once per minute) record the size of all postgres processes. Send an alert if one of them is "too large". This should give you a good idea what the processes were doing at the time they allocated that memory, so that you can reproduce the problem. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --9amGYk9869ThD9tj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl9jnF4ACgkQ8g5IURL+ KF0gOw//bhZj1i33OSeN9IhlnMqruWdypUiRmKM3zrtHDXUvTjm/CQZeIx45+86s fsk6GUPreubrYbTlsGqPrEvYFGqGQ2BnYULrKARK55EssfpTaM/Aol+z4hvoL+4B utA3ptECGu0QGOpSWp4VwB/aiV7l82iyiN695OwPHKSFj5CrlvcjsrAKCB++MApQ 5MjCEXqfMyFs3mGtL9Tzp+HluoOJHdZHQAhF5x8tazQx9Bz/Bm+Z0BzB76NAE9Nu BZSYVX463JUU2qmHkzOZGKxdfShMM5VxIuUSAYTkT550GIk2rtOebiUizVRy0wdP 4yvwSkKM9q6zYW3SN3gbhDINY0ueGzbi9inK7wwnpH1izLZkK4FMQmqK4zGS+G55 7ne2uP2pQk249FsBCe1uM4pIXIDjvADmcOA9Bg6zAUAigE8DuKZWwdJ0R3x8cv+9 kuBlkKLf91TWwx+BOzav/cMBMjWkjQe4GtpXqqDNMvbdW4TXLpJQI6KFDJd82ax7 1/hAiu8T6k9G1sKr1GZHjscQtQR1LIwLtj67le+KKsI0L/RAgO0sR/337zz6Lfu4 Sy8SOKd345F7sb21GOLjqhWYdAsoLyvfQOCb/QymJvzdeuMgK6jypFBlahJ1497d tIsj+7KcOx4vPaUI+9yhDZMhWmrpUVwSnfkKYE5pRPJlQkxdWqI= =C7wu -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--