pythonprofilers / memory_profiler

Monitor Memory usage of Python code
http://pypi.python.org/pypi/memory_profiler
Other
4.39k stars 380 forks source link

Fix: Large negative increments #350

Open bsjones109 opened 2 years ago

bsjones109 commented 2 years ago

Issue #219

During loops the memory may decrease from one iteration to the next. Storing max(memory, prev_line_memory) can lead to ongoing decrements of the increment value since only the max value is stored and it is used to calculate the change to the increment. This change stores the most recent memory value instead of the max.

nyngwang commented 2 years ago

FYI: the current implementation seems wrong: (Specifically, the calculation seems wrong starting from the line 111, included)

fabianp commented 2 years ago

@nyngwang does the fix in this PR solve your problem?

bsjones109 commented 2 years ago

FYI: the current implementation seems wrong: (Specifically, the calculation seems wrong starting from the line 111, included)

@nyngwang Is it because the values seem too large? You can divide the number in the third column by the number in the last column to get the average increment/decrement. It's actually quite small. The second column is the max increment seen.

nyngwang commented 2 years ago

@fabianp No.