Hi,
On 2024-09-19 07:30:54 +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18624
> Logged by: Abhishek Mittal
> Email address: abhmittal@gmail.com
> PostgreSQL version: 12.16
> Operating system: ubuntu0.20.04.1
> Description:
> 4. We observe that the RES (resident) memory reported by the top command
> continuously increases. This memory increase only occurs when we run queries
> on this connection. If no queries are executed, the RES memory remains
> stable.
I suspect what you may be seeing is that RES is increased the first time a
backend references a shared memory page, unless huge page are used. Because
you're copying more and more data in, more and more of shared buffers are
going to be used.
Do you see RES increasing to something substantially larger than
shared_buffers?
You can query the different aspects making up RES by doing
grep Rss /proc/$PID/status
which will return something like:
RssAnon: 3364 kB
RssFile: 11196 kB
RssShmem: 2204444 kB
Where only RssAnon really is memory usage.
FWIW, this was for a pid that was doing lots of COPYs and where top showed a
memory usage of 2GB.
Greetings,
Andres Freund