so apparent memory leak seems to be just connection.queries debugging of django.
[wolnelektury.git] / apps / catalogue / utils.py
index 1ac0ee8..1060670 100644 (file)
@@ -300,3 +300,16 @@ class AppSettings(object):
         if hasattr(self, more):
             value = getattr(self, more)(value)
         return value
+
+
+def trim_query_log(trim_to=25):
+    """
+connection.queries includes all SQL statements -- INSERTs, UPDATES, SELECTs, etc. Each time your app hits the database, the query will be recorded.
+This can sometimes occupy lots of memory, so trim it here a bit.
+    """
+    if settings.DEBUG:
+        from django.db import connection
+        connection.queries = trim_to > 0 \
+            and connection.queries[-trim_to:] \
+            or []
+