{"id":15103758,"url":"https://github.com/talkinnl/dont-leak","last_synced_at":"2026-02-19T05:02:44.302Z","repository":{"id":231488284,"uuid":"778689471","full_name":"talkinnl/dont-leak","owner":"talkinnl","description":"A simple library to reduce memory usage during a phpunit run.","archived":false,"fork":false,"pushed_at":"2024-09-12T13:53:29.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T13:58:41.117Z","etag":null,"topics":["php","phpunit"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/talkinnl.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":"2024-03-28T07:54:40.000Z","updated_at":"2024-09-12T13:53:33.000Z","dependencies_parsed_at":"2024-04-05T14:27:59.901Z","dependency_job_id":"4a2cfa82-1de4-44d8-9165-ea45bc715f00","html_url":"https://github.com/talkinnl/dont-leak","commit_stats":null,"previous_names":["talkinnl/dont-leak"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/talkinnl/dont-leak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talkinnl%2Fdont-leak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talkinnl%2Fdont-leak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talkinnl%2Fdont-leak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talkinnl%2Fdont-leak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talkinnl","download_url":"https://codeload.github.com/talkinnl/dont-leak/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talkinnl%2Fdont-leak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018713,"owners_count":26086449,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php","phpunit"],"created_at":"2024-09-25T19:41:54.902Z","updated_at":"2025-10-14T10:07:10.501Z","avatar_url":"https://github.com/talkinnl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Don't Leak\n\n[![PHP Composer and unittest](https://github.com/talkinnl/dont-leak/actions/workflows/php.yml/badge.svg)](https://github.com/talkinnl/dont-leak/actions/workflows/php.yml)\n\n----\n\n## ARCHIVED, NO LONGER NEEDED.\n\nThis package is no longer needed, since PHPUnit now destructs the TestCase instances during the run.\n\n- Initial PR by Sebastian :fire: , [PR 5861](https://github.com/sebastianbergmann/phpunit/pull/5861), released in PHPUnit [10.5.21 / 11.2.2](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.21).\n- Final PR by me :sunglasses: , [PR 5875](https://github.com/sebastianbergmann/phpunit/pull/5875#issuecomment-2179933860), released in PHPUnit [10.5.23 / 11.2.4](https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.23)\n\n----\n\nPHPUnit keeps all Test instance in memory for the whole run.\nThis causes used memory to continuously increase, unless you clean up all your properties during a tearDown().\n\nThere's No Doubt you'll eventually forget this tedious task.\n\n## Installation\n\n```shell\ncomposer require --dev talkinnl/dont-leak\n```\n\n## Usage\n\nIn your Test classes, add this as a **very last line** of your tearDown().\n\nMaybe you'd like to always use a common parent class so you'll never forget.\n```php\n    protected function tearDown(): void\n    {\n        // Start with some of your cleanups which are still needed.\n        // Maybe removing files made during the test etc\n        \n        // Always call your parents; they might get worried. :)\n        parent::tearDown();\n        \n        // Unset any properties, prevent memory leaks.\n        DontLeak::freeOwnProperties($this);\n    }\n```\n\n## What does it do?\n\n`DontLeak::freeOwnProperites($object)` unsets all properties reachable in your own scope of given $object, and all private properties of parent objects. \n\nProperties defined by PHPUnit WON'T be touched.\n\n## What's next\n\nI'd really like it if this package would be become obsolete thanks to PHPUnit changing the behaviour.\n\nPlease read, and maybe vote --\u003e \nhttps://github.com/sebastianbergmann/phpunit/issues/4705\n\n## Credits\n\nMany suggestions of a tearDown which uses reflection to clean up exist scattered across Stack Overflow, Reddit, Github, etc.\n\nThe implementation was heavily inspired by https://gist.github.com/malarzm/e8c6141b510708e52c8535d2a13cd613 , which unsets instead of assigning null, and also clears private properties of safe parents.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalkinnl%2Fdont-leak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalkinnl%2Fdont-leak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalkinnl%2Fdont-leak/lists"}