diff options
author | Erik Johnston <erik@matrix.org> | 2021-04-26 10:29:26 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2021-04-26 10:29:26 +0100 |
commit | 0c9bab290f921514532e73fdce6ef5d0b87222d7 (patch) | |
tree | 4a2e8890c520e70ce81b73f61a4d482e21658b8a | |
parent | Don't have a global Asizer (diff) | |
download | synapse-0c9bab290f921514532e73fdce6ef5d0b87222d7.tar.xz |
Ignore singletons
-rw-r--r-- | synapse/util/caches/lrucache.py | 4 |
1 files changed, 4 insertions, 0 deletions
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) |