Skip to content

Instantly share code, notes, and snippets.

@mei-li
Last active February 22, 2021 14:53
Show Gist options
  • Save mei-li/facff33799d55544a61bf5a4953a9050 to your computer and use it in GitHub Desktop.
Save mei-li/facff33799d55544a61bf5a4953a9050 to your computer and use it in GitHub Desktop.

Get process memory

https://medium.com/survata-engineering-blog/monitoring-memory-usage-of-a-running-python-program-49f027e3d1ba

Python memory management (how it works):

https://rushter.com/blog/python-memory-managment/

https://rushter.com/blog/python-garbage-collector/

Very useful articles

https://dzone.com/articles/python-memory-issues-tips-and-tricks

Memory Profiler

Main features:

Line by line memory usage. By decorating a function you can get information about the memory usage in each line of code.

Time based memory usage. mprof run run_service --app-ini= export. It will execute the export service and analyze the memory usage. To plot it: mprof plot

Fil Profiler

This profiler helps you find the peak memory usage of the application. It will generate a waterfall style graph where you can see the stack trace of the most memory consuming parts of the application. Run like this: fil-profile run run_service --app-ini= export

Muppy

Dumping or Diffing memory object status - https://pythonhosted.org/Pympler/muppy.html

More info

https://medium.com/zendesk-engineering/hunting-for-memory-leaks-in-python-applications-6824d0518774

http://tech.labs.oliverwyman.com/blog/2008/11/14/tracing-python-memory-leaks/

https://pythonspeed.com/articles/python-server-memory-leaks/

https://pythonhosted.org/Pympler/muppy.html

https://github.com/P403n1x87/austin - Connect to preview

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