Open kspieks opened 5 years ago
As an update, the above issue may have been caused by using the default sampling rate of 0.1 seconds. When running this again with -T 0.001
, I get the output below which decreases the memory usage but doesn't show the corresponding decrement, which is mentioned in issue #253 as well. Is it correct that the sampling rate is the only thing to consider here?
3 37.3 MiB 37.3 MiB @profile
4 def my_func():
5 45.0 MiB 7.6 MiB a = [1] * (10 ** 6)
6 197.5 MiB 152.6 MiB b = [2] * (2 * 10 ** 7)
7 45.0 MiB 0.0 MiB del b
8 45.0 MiB 0.0 MiB b = None
9 45.0 MiB 0.0 MiB gc.collect()
10 45.0 MiB 0.0 MiB return a
Same with macOS 12.0.1 and python 3.11.2
In contrast to some other open issues, Mem usage and Increment seem consistent for me. However, I tried 3 methods of deleting b (
del b
, assigning b to None, and using the garbage collector) and none of them freed the memory. Is mprof not correctly tracking the removal of b? If the memory is not actually being released, could someone help me understand why? I get the same result when runningmprof run example.py
andpython example.py
Line # Mem usage Increment Line Contents