0
Line #    Mem usage    Increment  Occurrences   Line Contents
=============================================================
    34    101.5 MiB    101.5 MiB           1   @profile
    35                                         def memory_func2():
    36
    37                                              #optMiningMainFunc()
    38    110.9 MiB  -7837.3 MiB     1000003        foo = ['bar' for _ in range(1000000)]
    39    103.3 MiB     -7.7 MiB           1        del foo

When I run this code, mprofiler shows ~2.8 MiB did not deallocated.

But, when I run again,

Line #    Mem usage    Increment  Occurrences   Line Contents
=============================================================
    34    101.6 MiB    101.6 MiB           1   @profile
    35                                         def memory_func2():
    36
    37                                              #optMiningMainFunc()
    38    109.2 MiB  -1591.6 MiB     1000003        foo = ['bar' for _ in range(1000000)]
    39    101.6 MiB     -7.6 MiB           1        del foo

it deallocated all.

I saw similar post: https://stackoverflow.com/a/15457947/11645616

where memory fragmentation (not sure it is correct word usage), can cause to not release all memory.

But, is there any specific case that we can know or avoid this situation? Because if we run multiple days, one program can have large memory leakage while other program is not,

Park Bo
  • 53
  • 7

0 Answers0