summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-04-23 17:16:49 +0100
committerErik Johnston <erik@matrix.org>2021-04-23 17:16:49 +0100
commit5003bd29d24c9ecb74ffe7c8d1898c339ef317f3 (patch)
tree074e166077ea635f6fe59b16061055cafb73f2f3
parentTrack memory usage of caches (diff)
downloadsynapse-5003bd29d24c9ecb74ffe7c8d1898c339ef317f3.tar.xz
Don't have a global Asizer
-rw-r--r--synapse/util/caches/lrucache.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index 97cc77156a..fdf3b726b0 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -36,9 +36,6 @@ from synapse.util.caches.treecache import TreeCache
 try:
     from pympler.asizeof import Asizer
 
-    sizer = Asizer()
-    sizer.exclude_refs((), None, "")
-
     def _get_size_of(val: Any, *, recurse=True) -> int:
         """Get an estimate of the size in bytes of the object.
 
@@ -47,12 +44,14 @@ try:
             recurse: If true will include referenced values in the size,
                 otherwise only sizes the given object.
         """
+        sizer = Asizer()
+        sizer.exclude_refs((), None, "")
         return sizer.asizeof(val, limit=100 if recurse else 0)
 
 
 except ImportError:
 
-    def _get_size_of(val: Any, recurse=True) -> int:
+    def _get_size_of(val: Any, *, recurse=True) -> int:
         return 0