DEV Community

moogoo
moogoo

Posted on

1

Check Python Memory Usage

Build-in libraries

import tracemalloc

print(tracemalloc.start())
# ...
# my ugly code
# ...
print(tracemalloc.get_traced_memory())

# shows (current_usage, peak)
Enter fullscreen mode Exit fullscreen mode

Tools

# need pip install memory_profiler
from memory_profiler import profile

@profile
def my_ugly_func():
  # ...
  # ...

# show memory usage line by line
Enter fullscreen mode Exit fullscreen mode

Other

Tkinter initial use 41.9 MB

Image description

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay