From f3a8b88a7050af0a6896757dbc1e4358bafd7162 Mon Sep 17 00:00:00 2001 From: Brandon Jones <22887874+bsjones109@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:09:54 +0000 Subject: [PATCH 1/3] Update memory_profiler.py Keep actual previous line memory instead of max in trace(). --- memory_profiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory_profiler.py b/memory_profiler.py index 6d26422..b1519fe 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -680,7 +680,7 @@ def trace(self, code, lineno, prev_lineno): occ_count = self[code][lineno][2] + 1 if lineno in self[code] else 1 self[code][lineno] = ( previous_inc + (memory - prev_line_memory), - max(memory, previous_memory), + memory, occ_count, ) From d07ac980dddb16644e0d0ef83c5fad2fcebc7f7b Mon Sep 17 00:00:00 2001 From: Brandon Jones <22887874+bsjones109@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:09:54 +0000 Subject: [PATCH 2/3] Keep previous line memory instead of max in trace(). --- memory_profiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory_profiler.py b/memory_profiler.py index 6d26422..b1519fe 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -680,7 +680,7 @@ def trace(self, code, lineno, prev_lineno): occ_count = self[code][lineno][2] + 1 if lineno in self[code] else 1 self[code][lineno] = ( previous_inc + (memory - prev_line_memory), - max(memory, previous_memory), + memory, occ_count, ) From aa95e34cf6be3c51ba4aa3ccd014f6d40fc32392 Mon Sep 17 00:00:00 2001 From: Brandon Jones <22887874+bsjones109@users.noreply.github.com> Date: Mon, 7 Feb 2022 18:35:25 +0000 Subject: [PATCH 3/3] Update memory_profiler.py Keep max memory display, but use actual memory for increment. --- memory_profiler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/memory_profiler.py b/memory_profiler.py index b1519fe..53cfe84 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -676,12 +676,13 @@ def trace(self, code, lineno, prev_lineno): previous_inc = prev_value[0] if prev_value else 0 prev_line_value = self[code].get(prev_lineno, None) if prev_lineno else None - prev_line_memory = prev_line_value[1] if prev_line_value else 0 + prev_line_memory = prev_line_value[3] if prev_line_value else 0 occ_count = self[code][lineno][2] + 1 if lineno in self[code] else 1 self[code][lineno] = ( previous_inc + (memory - prev_line_memory), - memory, + max(memory, previous_memory), occ_count, + memory, ) def items(self):