diff --git a/pep-0454.txt b/pep-0454.txt index 2334b7b8b..8d2beca29 100644 --- a/pep-0454.txt +++ b/pep-0454.txt @@ -88,6 +88,23 @@ implementations of Python may not be able to provide it. API === +To trace most memory blocks allocated by Python, the module should be +enabled as early as possible by setting the ``PYTHONTRACEMALLOC`` +environment variable to ``1``, or by using ``-X tracemalloc`` command +line option. The ``tracemalloc.enable()`` function can be called at +runtime to start tracing Python memory allocations. + +By default, a trace of an allocated memory block only stores the most +recent frame (1 frame). To store 25 frames at startup: set the +``PYTHONTRACEMALLOC`` environment variable to ``25``, or use the ``-X +tracemalloc=25`` command line option. The ``set_traceback_limit()`` +function can be used at runtime to set the limit. + +By default, Python memory blocks allocated in the ``tracemalloc`` module +are ignored using a filter. Use ``clear_filters()`` to trace also these +memory allocations. + + Main Functions --------------