{"id":13625210,"url":"https://github.com/bloomberg/pytest-memray","last_synced_at":"2025-05-14T15:05:44.923Z","repository":{"id":37457338,"uuid":"483352305","full_name":"bloomberg/pytest-memray","owner":"bloomberg","description":"pytest plugin for easy integration of memray memory profiler","archived":false,"fork":false,"pushed_at":"2025-01-24T22:24:30.000Z","size":471,"stargazers_count":375,"open_issues_count":10,"forks_count":26,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-20T15:59:19.952Z","etag":null,"topics":["memory","memory-leak","memory-leak-detection","memory-profiler","profiler","pytest","python"],"latest_commit_sha":null,"homepage":"https://pytest-memray.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloomberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-19T17:52:19.000Z","updated_at":"2025-04-20T03:54:35.000Z","dependencies_parsed_at":"2023-02-09T03:31:29.354Z","dependency_job_id":"583aeead-b2db-4310-89db-7d8b74b29be3","html_url":"https://github.com/bloomberg/pytest-memray","commit_stats":{"total_commits":97,"total_committers":10,"mean_commits":9.7,"dds":0.711340206185567,"last_synced_commit":"31b0a28ad7a82766cad980e6590e2a5ffe30ea03"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpytest-memray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpytest-memray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpytest-memray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpytest-memray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloomberg","download_url":"https://codeload.github.com/bloomberg/pytest-memray/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254168845,"owners_count":22026206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["memory","memory-leak","memory-leak-detection","memory-profiler","profiler","pytest","python"],"created_at":"2024-08-01T21:01:52.483Z","updated_at":"2025-05-14T15:05:44.887Z","avatar_url":"https://github.com/bloomberg.png","language":"Python","readme":"\u003cimg src=\"https://raw.githubusercontent.com/bloomberg/pytest-memray/main/docs/_static/images/logo.png\" width=\"70%\" style=\"display: block; margin: 0 auto\"  alt=\"logo\"/\u003e\n\n# pytest-memray\n\n[![PyPI](https://img.shields.io/pypi/v/pytest-memray?style=flat-square)](https://pypi.org/project/pytest-memray)\n[![PyPI - Implementation](https://img.shields.io/pypi/implementation/pytest-memray?style=flat-square)](https://pypi.org/project/pytest-memray)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-memray?style=flat-square)](https://pypi.org/project/pytest-memray)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/pytest-memray?style=flat-square)](https://pypistats.org/packages/pytest-memray)\n[![PyPI - License](https://img.shields.io/pypi/l/pytest-memray?style=flat-square)](https://opensource.org/licenses/MIT)\n[![Tests](https://github.com/bloomberg/pytest-memray/actions/workflows/build.yml/badge.svg)](https://github.com/bloomberg/pytest-memray/actions/workflows/build.yml)\n![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)\n\npytest-memray is a pytest plugin for easy integration of\n[memray](https://github.com/bloomberg/memray).\n\n## Installation\n\npytest-memray requires Python 3.8 or higher and can be easily installed using most\ncommon Python packaging tools. We recommend installing the latest stable release from\n[PyPI](https://pypi.org/project/pytest-memray/) with pip:\n\n```shell\npip install pytest-memray\n```\n\n## Documentation\n\nYou can find the latest documentation available\n[here](https://pytest-memray.readthedocs.io/en/latest/).\n\n## Quick introduction\n\nTo use the plugin in a pytest run, simply add `--memray` to the command line invocation:\n\n```shell\npytest --memray tests\n```\n\nAfter the test suite runs you'll see a memory report printed:\n\n```bash\n=================================== test session starts ====================================\nplatform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0\ncachedir: /v/.pytest_cache\nrootdir: /w\nplugins: memray-1.1.0\ncollected 2 items\n\ndemo/test_ok.py .M                                                                   [100%]\n\n========================================= FAILURES =========================================\n____________________________________ test_memory_exceed ____________________________________\nTest was limited to 100.0KiB but allocated 117.2KiB\n------------------------------------ memray-max-memory -------------------------------------\nTest is using 117.2KiB out of limit of 100.0KiB\nList of allocations:\n\t- \u003clistcomp\u003e:/w/demo/test_ok.py:17 -\u003e 117.2KiB\n\n====================================== MEMRAY REPORT =======================================\nAllocations results for demo/test_ok.py::test_memory_exceed\n\n\t 📦 Total memory allocated: 117.2KiB\n\t 📏 Total allocations: 30\n\t 📊 Histogram of allocation sizes: |█|\n\t 🥇 Biggest allocating functions:\n\t\t- \u003clistcomp\u003e:/w/demo/test_ok.py:17 -\u003e 117.2KiB\n\n\nAllocations results for demo/test_ok.py::test_track\n\n\t 📦 Total memory allocated: 54.9KiB\n\t 📏 Total allocations: 71\n\t 📊 Histogram of allocation sizes: |█   ▅    |\n\t 🥇 Biggest allocating functions:\n\t\t- test_track:/w/demo/test_ok.py:12 -\u003e 39.1KiB\n\t\t- _compile_bytecode:\u003cfrozen importlib._bootstrap_external\u003e:672 -\u003e 7.2KiB\n\t\t- _call_with_frames_removed:\u003cfrozen importlib._bootstrap\u003e:241 -\u003e 4.7KiB\n\t\t- _call_with_frames_removed:\u003cfrozen importlib._bootstrap\u003e:241 -\u003e 1.8KiB\n\t\t- _is_marked_for_rewrite:/v/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:240 -\u003e 1.1KiB\n\n\n================================= short test summary info ==================================\nMEMORY PROBLEMS demo/test_ok.py::test_memory_exceed\n=============================== 1 failed, 1 passed in 0.01s ================================\n```\n\n## Configuration - CLI flags\n\n- `--memray` - activate memray tracking\n- `--most-allocations=MOST_ALLOCATIONS` - show the N tests that allocate most memory\n  (N=0 for all)\n- `--hide-memray-summary` - hide the memray summary at the end of the execution\n- `--memray-bin-path` - path where to write the memray binary dumps (by default a\n  temporary folder)\n- `--memray-bin-prefix` - prefix to use for the binary dump (by default a random UUID4\n  hex)\n- `--stacks=STACKS` - Show the N stack entries when showing tracebacks of memory allocations\n- `--native` - Show native frames when showing tracebacks of memory allocations (will be slower)\n- `--trace-python-allocators` - Record allocations made by the Pymalloc allocator (will be slower)\n- `--fail-on-increase` - Fail a test with the `limit_memory`` marker if it uses\n  more memory than its last successful run\n\n## Configuration - INI\n\n- `memray(bool)` - activate memray tracking\n- `most-allocations(string)` - show the N tests that allocate most memory (N=0 for all)\n- `hide_memray_summary(bool)` - hide the memray summary at the end of the execution\n- `stacks(int)` - Show the N stack entries when showing tracebacks of memory allocations\n- `native(bool)`- Show native frames when showing tracebacks of memory allocations (will be slower)\n- `trace_python_allocators(bool)` - Record allocations made by the Pymalloc allocator (will be slower)\n- `fail-on-increase(bool)` - Fail a test with the `limit_memory` marker if it\n  uses more memory than its last successful run\n\n## License\n\npytest-memray is Apache-2.0 licensed, as found in the [LICENSE](LICENSE) file.\n\n## Code of Conduct\n\n- [Code of Conduct](https://github.com/bloomberg/.github/blob/main/CODE_OF_CONDUCT.md)\n\nThis project has adopted a Code of Conduct. If you have any concerns about the Code, or\nbehavior which you have experienced in the project, please contact us at\nopensource@bloomberg.net.\n\n## Security Policy\n\n- [Security Policy](https://github.com/bloomberg/pytest-memray/security/policy)\n\nIf you believe you have identified a security vulnerability in this project, please send\nemail to the project team at opensource@bloomberg.net, detailing the suspected issue and\nany methods you've found to reproduce it.\n\nPlease do NOT open an issue in the GitHub repository, as we'd prefer to keep\nvulnerability reports private until we've had an opportunity to review and address them.\n\n## Contributing\n\nWe welcome your contributions to help us improve and extend this project!\n\nBelow you will find some basic steps required to be able to contribute to the project.\nIf you have any questions about this process or any other aspect of contributing to a\nBloomberg open source project, feel free to email opensource@bloomberg.net, and we'll\nget your questions answered as quickly as we can.\n\n### Contribution Licensing\n\nSince this project is distributed under the terms of an [open source license](LICENSE),\ncontributions that you make are licensed under the same terms. In order for us to be\nable to accept your contributions, we will need explicit confirmation from you that you\nare able and willing to provide them under these terms, and the mechanism we use to do\nthis is called a Developer's Certificate of Origin\n[(DCO)](https://github.com/bloomberg/.github/blob/main/DCO.md). This is very similar to\nthe process used by the Linux(R) kernel, Samba, and many other major open source\nprojects.\n\nTo participate under these terms, all that you must do is include a line like the\nfollowing as the last line of the commit message for each commit in your contribution:\n\n```git\nSigned-Off-By: Random J. Developer \u003crandom@developer.example.org\u003e\n```\n\nThe simplest way to accomplish this is to add `-s` or `--signoff` to your `git commit`\ncommand.\n\nYou must use your real name (sorry, no pseudonyms, and no anonymous contributions).\n\n### Steps\n\n- Create an Issue, selecting 'Feature Request', and explain the proposed change.\n- Follow the guidelines in the issue template presented to you.\n- Submit the Issue.\n- Submit a Pull Request and link it to the Issue by including \"#\u003cissue number\u003e\" in the\n  Pull Request summary.\n\n### Development\n\nThe project requires a Linux OS to work. To set up a DEV environment use tox (or\ndirectly the make targets). You can use Docker to run the test suite on non Linux as in\n(you can parametrize tox by passing additional arguments at the end):\n\n```shell\ndocker-compose run --rm test tox\n```\n","funding_links":[],"categories":["Python","Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Fpytest-memray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloomberg%2Fpytest-memray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Fpytest-memray/lists"}