summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2019-05-29 13:39:37 -0700
committerBryan Newbold <bnewbold@archive.org>2019-05-29 13:39:37 -0700
commit4579dc274924ce7987c6990f69a2b735a37ed7b4 (patch)
treed21e04229a41e147f26ad410e73ac83ba71afd4f
parent49a440f9ae3695cc493b3d4e244e99435c87a24f (diff)
downloadknowledge-4579dc274924ce7987c6990f69a2b735a37ed7b4.zip
knowledge-4579dc274924ce7987c6990f69a2b735a37ed7b4.tar.gz
python memory debugging
-rw-r--r--software/python.page21
1 files changed, 21 insertions, 0 deletions
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? <https://blog.fugue.co/2016-02-11-python-mocking-101.html>
+
+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()