samedi 29 novembre 2014

python - fuite de mémoire Django/Postgresql et les connexions persistantes - Stack Overflow


I'm seeing the memory utilization of some postgres processes growing up to 25% over time. The postgres connection is established by django which in turn is mostly just creating new records.


I'd like to understand why the postgres process is using so much memory although I did try to work around it by setting CONN_MAX_AGE to 600 in my django settings file. The postgres processes seem to exist for days though so I'm not convinced that CONN_MAX_AGE is doing anything.


I have DEBUG = False and am running Django 1.6.2. Any ideas on how to go about debugging this? Has anyone else seen a similar issue?




PostgreSQL probably isn't actually using tons more memory, it's just how your process accounting reports the memory use.


See



You might have real issues if your overall system RAM use goes up, and goes down again significantly when you terminate PostgreSQL backends using pg_terminate_backend. Most likely, though, what you're seeing is just more more shared memory pages touched by each backend.


PostgreSQL is pretty resistant to memory leaks due to its use of palloc and memory contexts to do heirachical context-sensitive memory management. Leaks within queries are uncommon, leaks that persist between queries are very rare. The only time I really see them is when custom C extensions are in use, or when people are using procedural languages like PL/Perl or PL/Python and are storing persistent information in the shared context.



I'm seeing the memory utilization of some postgres processes growing up to 25% over time. The postgres connection is established by django which in turn is mostly just creating new records.


I'd like to understand why the postgres process is using so much memory although I did try to work around it by setting CONN_MAX_AGE to 600 in my django settings file. The postgres processes seem to exist for days though so I'm not convinced that CONN_MAX_AGE is doing anything.


I have DEBUG = False and am running Django 1.6.2. Any ideas on how to go about debugging this? Has anyone else seen a similar issue?



PostgreSQL probably isn't actually using tons more memory, it's just how your process accounting reports the memory use.


See



You might have real issues if your overall system RAM use goes up, and goes down again significantly when you terminate PostgreSQL backends using pg_terminate_backend. Most likely, though, what you're seeing is just more more shared memory pages touched by each backend.


PostgreSQL is pretty resistant to memory leaks due to its use of palloc and memory contexts to do heirachical context-sensitive memory management. Leaks within queries are uncommon, leaks that persist between queries are very rare. The only time I really see them is when custom C extensions are in use, or when people are using procedural languages like PL/Perl or PL/Python and are storing persistent information in the shared context.


0 commentaires:

Enregistrer un commentaire