Clear memory being used by PHP

后端 未结 4 631
清歌不尽
清歌不尽 2021-02-05 21:54

I\'m running into an interesting problem. I\'m using PHPUnit, and my tests take more memory every single time I run them. Ie...

2.25 MB

2.5 MB

3.0 MB

4条回答
  •  北海茫月
    2021-02-05 22:31

    The technical details behind PHPUnit's garbage collection have already been covered by @edorian and @mauris, but I wanted to add that PHPUnit (at least in version 3.7.21, which I'm running) gives you the ability to add the comment:

    /**
     * @backupGlobals disabled
     */
    class MyClassTests extends PHPUnit_Framework_TestCase{}
    

    Before adding the annotation, I was roughly doubling my memory usage on each run of my test suite, the last one hitting about 1100 MB. Now they're running at 15 MB.

提交回复
热议问题