Skip to content

Instantly share code, notes, and snippets.

@myui
Created May 27, 2020 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myui/12ffe1a2e2649e0297a6cf0885301a6e to your computer and use it in GitHub Desktop.
Save myui/12ffe1a2e2649e0297a6cf0885301a6e to your computer and use it in GitHub Desktop.
from memory_profiler import profile
@profile()
def my_func():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
return a
my_func()
@myui
Copy link
Author

myui commented Nov 13, 2020

root@39683a1cba38:/# python test.py 
Filename: test.py

Line #    Mem usage    Increment   Line Contents
================================================
     3     13.8 MiB     13.8 MiB   @profile()
     4                             def my_func():
     5     21.3 MiB      7.5 MiB    a = [1] * (10 ** 6)
     6    173.9 MiB    152.6 MiB    b = [2] * (2 * 10 ** 7)
     7     21.4 MiB      0.0 MiB    del b
     8     21.4 MiB      0.0 MiB    return a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment