54

GitHub - Roave/no-leaks: PHPUnit Plugin for detecting Memory Leaks in code and t...

 5 years ago
source link: https://github.com/Roave/no-leaks
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

roave/no-leaks

This library is a PHPUnit plugin that detects memory leaks in tested code or tests.

Installation

composer require --dev roave/no-leaks

Usage

In your phpunit.xml configuration, add following section:

    <listeners>
        <listener class="Roave\NoLeaks\PHPUnit\CollectTestExecutionMemoryFootprints"/>
    </listeners>

    <extensions>
        <extension class="Roave\NoLeaks\PHPUnit\CollectTestExecutionMemoryFootprints"/>
    </extensions>

Then run:s

vendor/bin/roave-no-leaks

If any memory leaks are detected, you should see an output like following:

Exception: The following test produced memory leaks:
 * My\Leaky\Test::testSomething
 * My\Leaky\Test::testSomethingElse

Configuration and parameters

vendor/bin/roave-no-leaks supports all configuration parameters and console parameters of PHPUnit.

Known issues

Please be aware that this is not a full substitute for PHPUnit:

  • the output format is to be improved
  • memory leak detection for scalar types and arrays is not reliable
  • can fail depending on xdebug/phpdbg/php-sapi changes

Professional Support

If you need help with setting up this library in your project, you can contact us at [email protected] for consulting/support.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK