1

When I start Postgres DB in my machine, by default it creates 7 processes.

I understand that one among these processes is the main Postgres process and the remaining are background processes used by Postgres itself.

When my C# application connects to this Postgres DB instance and opens a connection, additional Postgres backend processes are getting created and it consumes some memory and finally when the connection is closed, these processes are getting killed and the memory they consumed is getting released.

But what I could observe is that, the memory consumption of the original 7 processes that Postgres created gradually increases and it is not getting released and due to this the system is eventually running out of memory.

Below is a screenshot of the Postgres instance that has been running in Docker for a few hours. As you can see it has consumed around 1.5GB of memory and there are only two additional processes apart from the 7 original processes. This memory will never be released and will keep adding up.

enter image description here

Is it normal for the default Postgres processes to consume this much memory and not release it? Or, am I doing something wrong with respect to handling the connections from the C# application (unlikely because the processes corresponding to these connections are getting killed and the corresponding memory is getting released) Or is the Postgres instance not configured correctly with the right configuration for my machine ?

Any advice/help would be much appreciated.

Charlieface
  • 52,284
  • 6
  • 19
  • 43
Ajay
  • 61
  • 3
  • 13
  • 2
    Yes, completely normal. There are ways to set maximum memory usage – Charlieface Dec 03 '21 at 13:23
  • 1
    Does this answer your question? [How to limit the memory that is available for PostgresSQL server?](https://stackoverflow.com/questions/28844170/how-to-limit-the-memory-that-is-available-for-postgressql-server) – Charlieface Dec 03 '21 at 13:23
  • @Charlieface Thanks for the link. Will try changing the default configurations and see if it helps. – Ajay Dec 03 '21 at 13:39
  • @a_horse_with_no_name The screenshot in my question is of a docker container running Postgres on Ubuntu. As you can see it has already consumed 1.5 GB of the total allotted memory of around 4GB. It will eventually add up to 4GB and when it happens, the container crashes/restarts. – Ajay Dec 03 '21 at 13:42

0 Answers0