Skip to content

some improvements over @demiurg906's pull request#119

Merged
fabianp merged 20 commits intomasterfrom
demiurg906-tracemalloc-backend
Aug 19, 2016
Merged

some improvements over @demiurg906's pull request#119
fabianp merged 20 commits intomasterfrom
demiurg906-tracemalloc-backend

Conversation

@fabianp
Copy link
Copy Markdown
Collaborator

@fabianp fabianp commented Aug 13, 2016

No description provided.

demiurg906 and others added 13 commits July 12, 2016 17:05
It is now possible to use ``tracemalloc`` to analyze memory usage Python
code on Python 3.4 and above. ``tracemalloc`` allows for more precise
measurements compared to ``psutil``. However, it only works either for
pure Python code or for C extensions allocating memory via ``PyMem_Alloc``.

To use the new backend code run ``memory_profiler`` with ``--backend``
option, e.g.

    $ python -m memory_profiler --backend=tracemalloc script.py

Also if you use ``memory_profiler`` with imported decorator you can specify
backend as an argument to the decorator function:

    @Profile(backend='tracemalloc')
    def f(n):
        a = [0] * n
        return a

``backend`` parameter to ``@profile`` has priority over ``--backend``.

Note that using ``tracemalloc`` in ``mprof`` and IPython magic is not
supported at the moment.
@demiurg906
Copy link
Copy Markdown
Contributor

@fabianp, I think your improvements works well and PR can be merged

@fabianp fabianp merged commit ac1193c into master Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants