From f2ee63805b149d5d7eb0be593947ed6986885ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Tue, 6 Jul 2021 16:14:13 +0200 Subject: [PATCH] pypy fix --- satella/instrumentation/memory/dump_frames_on.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/satella/instrumentation/memory/dump_frames_on.py b/satella/instrumentation/memory/dump_frames_on.py index 5de7f4d2..710119c0 100644 --- a/satella/instrumentation/memory/dump_frames_on.py +++ b/satella/instrumentation/memory/dump_frames_on.py @@ -13,13 +13,18 @@ def dump_memory_on(output: tp.TextIO = sys.stderr): Make sure you have enough memory to generate a breakdown. You can preallocate something at the start for example. + .. warning:: This will return size of 0 on PyPy + :param output: output, default is stderr """ top_scores = {} instances = {} for obj in gc.get_objects(): typ = type(obj) - size = sys.getsizeof(obj) + try: + size = sys.getsizeof(obj) + except TypeError: + size = 0 if typ in top_scores: top_scores[typ] += size instances[typ] += 1 -- GitLab