From 0c9bab290f921514532e73fdce6ef5d0b87222d7 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 26 Apr 2021 10:29:26 +0100 Subject: Ignore singletons --- synapse/util/caches/lrucache.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'synapse/util/caches/lrucache.py') diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py index fdf3b726b0..b018733288 100644 --- a/synapse/util/caches/lrucache.py +++ b/synapse/util/caches/lrucache.py @@ -44,6 +44,10 @@ try: recurse: If true will include referenced values in the size, otherwise only sizes the given object. """ + # Ignore singleton values when calculating memory usage. + if val in ((), None, ""): + return 0 + sizer = Asizer() sizer.exclude_refs((), None, "") return sizer.asizeof(val, limit=100 if recurse else 0) -- cgit 1.5.1