diff options
author | Bryan Newbold <bnewbold@archive.org> | 2019-05-29 13:39:37 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2019-05-29 13:39:37 -0700 |
commit | 4579dc274924ce7987c6990f69a2b735a37ed7b4 (patch) | |
tree | d21e04229a41e147f26ad410e73ac83ba71afd4f /software | |
parent | 49a440f9ae3695cc493b3d4e244e99435c87a24f (diff) | |
download | knowledge-4579dc274924ce7987c6990f69a2b735a37ed7b4.tar.gz knowledge-4579dc274924ce7987c6990f69a2b735a37ed7b4.zip |
python memory debugging
Diffstat (limited to 'software')
-rw-r--r-- | software/python.page | 21 |
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() |