From 4579dc274924ce7987c6990f69a2b735a37ed7b4 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 29 May 2019 13:39:37 -0700 Subject: python memory debugging --- software/python.page | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'software') diff --git a/software/python.page b/software/python.page index 0fd2531..0fc3c8d 100644 --- a/software/python.page +++ b/software/python.page @@ -205,3 +205,24 @@ and create a `pytest.ini` like: norecursedirs = .svn _build tmp* Need to mock? + +Debugging Memory Usage +------------------------ + +Most helpful tools I found were `psutil` and `pympler` (both need to be +installed). + + import os, psutil + process = psutil.Process(os.getpid()) + print(process.memory_info().rss) + # ... do some stuff ... + print(process.memory_info().rss) + +and + + from pympler import tracker + tr = tracker.SummaryTracker() + tr.print_diff() + + # ... do some stuff ... + tr.print_diff() -- cgit v1.2.3