Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #3530

pymemtrace - Tracing Python Memory Usage

Path csiph.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!fu-berlin.de!uni-berlin.de!not-for-mail
From Paul Ross <apaulross@gmail.com>
Newsgroups comp.lang.python.announce
Subject pymemtrace - Tracing Python Memory Usage
Date Tue, 17 Nov 2020 16:31:35 +0000
Lines 45
Approved python-announce-list@python.org
Message-ID <160563191847.7038.python-announce-list@python.org> (permalink)
Reply-To python-list@python.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding base64
X-Trace news.uni-berlin.de Ub9rpmYGz/KHozxIjwrZtgsgHeraK4kXxTLOT5vKA9mA==
Authentication-Results mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=BsII899B; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82.121/24': 0.03; 'url-ip:140.82/16': 0.03; 'library': 0.05; "python's": 0.05; 'usage': 0.05; 'execution': 0.07; 'module.': 0.09; 'reporting': 0.09; 'to:addr:python-announce-list': 0.09; 'url- ip:151.101.0.223/32': 0.09; 'url-ip:151.101.128.223/32': 0.09; 'url-ip:151.101.192.223/32': 0.09; 'url-ip:151.101.64.223/32': 0.09; 'subject:Python': 0.11; 'url-ip:140/8': 0.12; 'url:github': 0.15; 'python': 0.15; 'for\xc2\xa0': 0.16; 'levels,': 0.16; 'malloc': 0.16; 'plotting': 0.16; 'received:mail- wm1-x332.google.com': 0.16; 'runtime': 0.16; 'url- ip:104.17.32.82/32': 0.16; 'url-ip:104.17.32/24': 0.16; 'url- ip:104.17.33.82/32': 0.16; 'url-ip:104.17.33/24': 0.16; 'url:latest': 0.16; 'url:project': 0.16; 'url:pypi': 0.16; 'memory': 0.16; 'problem': 0.17; 'module': 0.18; 'calls': 0.20; 'object': 0.23; 'code': 0.24; 'written': 0.25; 'function': 0.28; 'there': 0.32; 'examples': 0.32; 'differences': 0.33; 'message- id:@mail.gmail.com': 0.33; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'url-ip:104.17/16': 0.36; 'change': 0.36; 'way': 0.36; 'total': 0.38; 'appropriate': 0.38; 'choose': 0.60; 'per': 0.60; 'costs': 0.63; 'hope': 0.63; 'within': 0.64; 'down': 0.64; 'cost': 0.64; 'range': 0.65; 'free': 0.66; 'caused': 0.68; 'low': 0.68; 'technical': 0.68; 'significant': 0.69; 'url:index': 0.69; 'limited,': 0.70; 'logging': 0.70; 'tools': 0.72; 'skip:* 10': 0.72; 'tracking': 0.77; 'paul': 0.81; 'allocated': 0.84; 'analysing': 0.84; 'itself.': 0.84; 'measuring': 0.84; 'convenience': 0.91; 'hand.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wcvI6GlI2ndqc1AgeBGBHBzfxS5L43ICsoYhEc+8624=; b=BsII899Bm1TaCZ6JTAMLnacPcf+5hu8jng03jGxSAD46/KEplH7rtawTW/oYDT/FuH BsVt3gnY/YqwsiKivkTr0dN+o5yr5r/tiNxr7pCrpyw9DYOK0ilErlhHmwFZZBycJ89A ibHjed4eK4MDMHZp4ZeJoysmg/eYE0r9z3kqH33SdQnIhz0GiBC+7DbcdgW7eh2CMFc0 Szm4YY0U41K+LrrckHUQw/NsTzVDn3sYZiYSezz98sNIHdpxBuInqCARRbD+ilY8ayUW lSyq5q8p43Xa2rKrr6UXFrdi5e2TE2f42ChStoVDa/Di8m6oxWJk9K2aw7Ef07W5pvJT szFQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wcvI6GlI2ndqc1AgeBGBHBzfxS5L43ICsoYhEc+8624=; b=pvIVGeuQfWgSk6HzlonmHsdZg1HRYh1nqyPU6IQ3FjalQHzLPaeRamY5FGU8RG6raF BegvYAK8L2PAQFYtU9MKnCCa7ycf9GJyOkX5Mxv4VYFnu2MsyQhuUlQCh8R2kCIRjq+m q9nKv9NgbOAlbBJz1FEtlTSxm2NGXqulSR2hcI0DM1J8i81kjzKmDp3mhDYVV+Kx79M3 4+AC9DrgG3gn63AH8RqLtZfs5zYkIn5lzE/8asy/Es/chradRiZV4ywIUpomMM3/UexR YovsdQdqLVgby7BQ2GaekHsC9PoQWH0aQKS66JSn6Uyreu3SCrWvEis0QNzGJSUjzbZZ qMYw==
X-Gm-Message-State AOAM531JfnrOMh8IFs6Ez3PUd2/RxbNfTvcyl8vMM0TGTdl05g0d2lw/ kV9Pzi5PJbvXJxmANujEWF4rFO0Uhg7l03S+i2USnZLopuw=
X-Google-Smtp-Source ABdhPJympo5kxRUd7c3+qckw07Sn4RMo8qNElVE/1kNfi2XIb5PAdXAXuc1bXdu2mEOnirLYhhQ7h4u48UNgYkjLzVo=
X-Received by 2002:a7b:c11a:: with SMTP id w26mr448464wmi.131.1605630708067; Tue, 17 Nov 2020 08:31:48 -0800 (PST)
X-MailFrom apaulross@gmail.com
X-Mailman-Rule-Hits emergency
X-Mailman-Rule-Misses dmarc-mitigation; no-senders; approved
Message-ID-Hash UVRVK4F5AIU2UDSHBIGTFIBTN67EHMP5
X-Message-ID-Hash UVRVK4F5AIU2UDSHBIGTFIBTN67EHMP5
X-Mailman-Approved-At Tue, 17 Nov 2020 11:51:46 -0500
X-Content-Filtered-By Mailman/MimeDel 3.3.2
X-Mailman-Version 3.3.2
Precedence list
List-Id Announcement-only list for the Python programming language <python-announce-list.python.org>
Archived-At <https://mail.python.org/archives/list/python-announce-list@python.org/message/UVRVK4F5AIU2UDSHBIGTFIBTN67EHMP5/>
List-Archive <https://mail.python.org/archives/list/python-announce-list@python.org/>
List-Help <mailto:python-announce-list-request@python.org?subject=help>
List-Post <mailto:python-announce-list@python.org>
List-Subscribe <mailto:python-announce-list-join@python.org>
List-Unsubscribe <mailto:python-announce-list-leave@python.org>
Xref csiph.com comp.lang.python.announce:3530

Show key headers only | View raw


Welcome to *pymemtrace*, a collection of tools for monitoring and analysing
Python's memory usage including that of Python Extensions.
These tools work at various levels, at different granularities and with
different runtime costs so you can choose one appropriate to the problem at
hand.
They range from periodically measuring total memory usage down to reporting
every malloc and free call per Python line or C function call.

The tools are:

* *process* is a very lightweight way of logging the total memory usage at
regular time intervals.
  It can plot memory over time with plotting programs such as gnuplot.
  Some examples
https://pymemtrace.readthedocs.io/en/latest/examples/process.html
* *cPyMemTrace* is a memory tracer written in C that can report total
memory usage for every function call/return for
  both C and Python sections.
  Some examples:
https://pymemtrace.readthedocs.io/en/latest/examples/c_py_mem_trace.html
  and a technical note on cPyMemTrace:
https://pymemtrace.readthedocs.io/en/latest/tech_notes/cPyMemTrace.html.
* *DTrace*: There are a number of D scripts that can trace the low level
``malloc()`` and ``free()`` system calls and
  report how much memory was allocated and by whom.
  Some DTrace examples:
https://pymemtrace.readthedocs.io/en/latest/examples/dtrace.html
  and a technical note on DTrace
https://pymemtrace.readthedocs.io/en/latest/tech_notes/dtrace.html
* *trace_malloc* is a convenience wrapper around the Python standard
library tracemalloc module.
  This can take memory snapshots before and after code blocks and show the
change in memory caused by that code by module and line compensating for
the cost of tracemalloc itself.
  Some trace_malloc examples
https://pymemtrace.readthedocs.io/en/latest/examples/trace_malloc.html
* *debug_malloc_stats* is a wrapper around the sys._debugmallocstats
function that can take snapshots of
  memory before and after code execution and report the significant
differences in the Python small object allocator.
  Some debug_malloc_stats examples
https://pymemtrace.readthedocs.io/en/latest/examples/debug_malloc_stats.html

Within the documentation is also some (rather limited, for the moment)
advice on tracking down memory leaks with Python extensions.

On PyPi: https://pypi.org/project/pymemtrace/
Project: https://github.com/paulross/pymemtrace
Documentation: https://pymemtrace.readthedocs.io/en/latest/index.html

I hope that you find this useful as I do!

Paul Ross.

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

pymemtrace - Tracing Python Memory Usage Paul Ross <apaulross@gmail.com> - 2020-11-17 16:31 +0000

csiph-web