在 Laravel 6 中运行 phpunit 时报错:PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 69632 bytes)
1、在 Laravel 6 中运行 phpunit 时报错:PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 69632 bytes)。如图1
PS E:\wwwroot\object> ./vendor/bin/phpunit PHPUnit 7.5.20 by Sebastian Bergmann and contributors. Esetup:14.95MB memory_limit:1024M tearDown:47.17MB memory_limit:1024M Esetup:47.36MB memory_limit:1024M tearDown:55.27MB memory_limit:1024M Esetup:56.22MB memory_limit:1024M tearDown:64.15MB memory_limit:1024M Esetup:64.18MB memory_limit:1024M tearDown:72.11MB memory_limit:1024M Esetup:72.14MB memory_limit:1024M tearDown:80.07MB memory_limit:1024M Esetup:80.1MB memory_limit:1024M tearDown:88.03MB memory_limit:1024M Esetup:88.06MB memory_limit:1024M tearDown:96.02MB memory_limit:1024M Esetup:96.05MB memory_limit:1024M tearDown:103.98MB memory_limit:1024M Esetup:104.01MB memory_limit:1024M tearDown:111.5MB memory_limit:1024M Esetup:111.61MB memory_limit:1024M tearDown:119.54MB memory_limit:1024M Esetup:119.57MB memory_limit:1024M tearDown:127.5MB memory_limit:1024M Esetup:127.62MB memory_limit:1024M tearDown:135.55MB memory_limit:1024M Esetup:135.58MB memory_limit:1024M tearDown:143.51MB memory_limit:1024M Esetup:143.64MB memory_limit:1024M tearDown:151.57MB memory_limit:1024M Esetup:151.6MB memory_limit:1024M tearDown:159.53MB memory_limit:1024M Esetup:159.56MB memory_limit:1024M tearDown:167.49MB memory_limit:1024M Esetup:167.52MB memory_limit:1024M tearDown:175.51MB memory_limit:1024M Esetup:175.54MB memory_limit:1024M tearDown:183.16MB memory_limit:1024M Esetup:183.19MB memory_limit:1024M tearDown:191.12MB memory_limit:1024M Esetup:191.15MB memory_limit:1024M tearDown:199.08MB memory_limit:1024M Esetup:199.11MB memory_limit:1024M tearDown:207.04MB memory_limit:1024M Esetup:207.07MB memory_limit:1024M tearDown:215MB memory_limit:1024M Esetup:215.03MB memory_limit:1024M tearDown:222.96MB memory_limit:1024M Esetup:222.99MB memory_limit:1024M tearDown:230.92MB memory_limit:1024M Esetup:231.01MB memory_limit:1024M tearDown:238.94MB memory_limit:1024M Esetup:238.97MB memory_limit:1024M tearDown:246.9MB memory_limit:1024M Esetup:246.93MB memory_limit:1024M tearDown:254.86MB memory_limit:1024M Esetup:254.89MB memory_limit:1024M tearDown:262.72MB memory_limit:1024M Esetup:262.75MB memory_limit:1024M tearDown:270.68MB memory_limit:1024M Esetup:270.71MB memory_limit:1024M tearDown:278.64MB memory_limit:1024M Esetup:278.67MB memory_limit:1024M tearDown:286.6MB memory_limit:1024M Esetup:286.63MB memory_limit:1024M tearDown:294.56MB memory_limit:1024M Esetup:294.59MB memory_limit:1024M tearDown:302.52MB memory_limit:1024M Esetup:302.62MB memory_limit:1024M tearDown:310.55MB memory_limit:1024M Esetup:310.58MB memory_limit:1024M tearDown:318.51MB memory_limit:1024M Esetup:318.54MB memory_limit:1024M tearDown:326.47MB memory_limit:1024M Esetup:326.5MB memory_limit:1024M tearDown:334.55MB memory_limit:1024M Esetup:334.58MB memory_limit:1024M tearDown:342.41MB memory_limit:1024M Esetup:342.44MB memory_limit:1024M tearDown:350.37MB memory_limit:1024M Esetup:350.4MB memory_limit:1024M tearDown:358.33MB memory_limit:1024M Esetup:358.36MB memory_limit:1024M tearDown:366.29MB memory_limit:1024M Esetup:366.32MB memory_limit:1024M tearDown:374.25MB memory_limit:1024M Esetup:374.28MB memory_limit:1024M tearDown:382.21MB memory_limit:1024M Esetup:382.24MB memory_limit:1024M tearDown:390.17MB memory_limit:1024M Esetup:390.2MB memory_limit:1024M tearDown:398.13MB memory_limit:1024M Esetup:398.16MB memory_limit:1024M tearDown:406.09MB memory_limit:1024M Esetup:406.12MB memory_limit:1024M tearDown:414.05MB memory_limit:1024M Esetup:414.08MB memory_limit:1024M tearDown:422.01MB memory_limit:1024M Esetup:422.08MB memory_limit:1024M tearDown:430.01MB memory_limit:1024M Esetup:430.04MB memory_limit:1024M tearDown:437.97MB memory_limit:1024M Esetup:438MB memory_limit:1024M tearDown:445.93MB memory_limit:1024M Esetup:445.96MB memory_limit:1024M tearDown:453.89MB memory_limit:1024M Esetup:453.92MB memory_limit:1024M tearDown:461.85MB memory_limit:1024M Esetup:461.88MB memory_limit:1024M tearDown:469.81MB memory_limit:1024M Esetup:469.84MB memory_limit:1024M tearDown:477.77MB memory_limit:1024M Esetup:477.8MB memory_limit:1024M tearDown:485.73MB memory_limit:1024M Esetup:485.76MB memory_limit:1024M tearDown:493.69MB memory_limit:1024M Esetup:493.72MB memory_limit:1024M tearDown:501.66MB memory_limit:1024M Esetup:501.69MB memory_limit:1024M tearDown:509.62MB memory_limit:1024M Esetup:509.65MB memory_limit:1024M tearDown:517.58MB memory_limit:1024M Esetup:517.61MB memory_limit:1024M tearDown:525.54MB memory_limit:1024M Esetup:525.57MB memory_limit:1024M tearDown:533.5MB memory_limit:1024M E 63 / 211 ( 29%) setup:533.53MB memory_limit:1024M tearDown:541.46MB memory_limit:1024M Esetup:541.52MB memory_limit:1024M tearDown:549.46MB memory_limit:1024M Esetup:549.49MB memory_limit:1024M tearDown:557.43MB memory_limit:1024M Esetup:557.46MB memory_limit:1024M tearDown:565.39MB memory_limit:1024M Esetup:565.42MB memory_limit:1024M tearDown:573.35MB memory_limit:1024M Esetup:573.38MB memory_limit:1024M tearDown:581.31MB memory_limit:1024M Esetup:581.43MB memory_limit:1024M tearDown:589.05MB memory_limit:1024M Esetup:589.08MB memory_limit:1024M tearDown:597.01MB memory_limit:1024M Esetup:597.04MB memory_limit:1024M tearDown:604.97MB memory_limit:1024M Esetup:605MB memory_limit:1024M tearDown:612.93MB memory_limit:1024M Esetup:612.96MB memory_limit:1024M tearDown:620.89MB memory_limit:1024M Esetup:620.92MB memory_limit:1024M tearDown:628.85MB memory_limit:1024M Esetup:628.88MB memory_limit:1024M tearDown:636.81MB memory_limit:1024M Esetup:636.84MB memory_limit:1024M tearDown:644.77MB memory_limit:1024M Esetup:644.8MB memory_limit:1024M tearDown:652.98MB memory_limit:1024M Esetup:653.01MB memory_limit:1024M tearDown:660.94MB memory_limit:1024M Esetup:660.97MB memory_limit:1024M tearDown:668.9MB memory_limit:1024M Esetup:668.93MB memory_limit:1024M tearDown:676.86MB memory_limit:1024M Esetup:676.89MB memory_limit:1024M tearDown:684.82MB memory_limit:1024M Esetup:684.89MB memory_limit:1024M tearDown:692.83MB memory_limit:1024M Esetup:692.85MB memory_limit:1024M tearDown:700.79MB memory_limit:1024M Esetup:700.81MB memory_limit:1024M tearDown:708.75MB memory_limit:1024M Esetup:708.77MB memory_limit:1024M tearDown:716.71MB memory_limit:1024M Esetup:716.73MB memory_limit:1024M tearDown:724.67MB memory_limit:1024M Esetup:724.69MB memory_limit:1024M tearDown:732.63MB memory_limit:1024M Esetup:732.65MB memory_limit:1024M tearDown:740.59MB memory_limit:1024M Esetup:740.61MB memory_limit:1024M tearDown:748.55MB memory_limit:1024M Esetup:748.58MB memory_limit:1024M tearDown:756.51MB memory_limit:1024M Esetup:756.54MB memory_limit:1024M tearDown:764.47MB memory_limit:1024M Esetup:764.5MB memory_limit:1024M tearDown:772.43MB memory_limit:1024M Esetup:772.51MB memory_limit:1024M tearDown:780.44MB memory_limit:1024M Esetup:780.47MB memory_limit:1024M tearDown:788.4MB memory_limit:1024M Esetup:788.43MB memory_limit:1024M tearDown:796.36MB memory_limit:1024M Esetup:796.39MB memory_limit:1024M tearDown:804.32MB memory_limit:1024M Esetup:804.35MB memory_limit:1024M tearDown:812.28MB memory_limit:1024M Esetup:812.31MB memory_limit:1024M tearDown:820.24MB memory_limit:1024M Esetup:820.27MB memory_limit:1024M tearDown:828.2MB memory_limit:1024M Esetup:828.23MB memory_limit:1024M tearDown:835.96MB memory_limit:1024M Esetup:835.99MB memory_limit:1024M tearDown:843.92MB memory_limit:1024M Esetup:843.95MB memory_limit:1024M tearDown:851.88MB memory_limit:1024M Esetup:851.91MB memory_limit:1024M tearDown:859.84MB memory_limit:1024M Esetup:859.87MB memory_limit:1024M tearDown:867.8MB memory_limit:1024M Esetup:867.83MB memory_limit:1024M tearDown:875.76MB memory_limit:1024M Esetup:875.79MB memory_limit:1024M tearDown:883.72MB memory_limit:1024M Esetup:883.75MB memory_limit:1024M tearDown:891.68MB memory_limit:1024M Esetup:891.71MB memory_limit:1024M tearDown:899.64MB memory_limit:1024M Esetup:899.67MB memory_limit:1024M tearDown:907.6MB memory_limit:1024M Esetup:907.66MB memory_limit:1024M tearDown:915.48MB memory_limit:1024M Esetup:915.51MB memory_limit:1024M tearDown:923.44MB memory_limit:1024M Esetup:923.47MB memory_limit:1024M tearDown:931.4MB memory_limit:1024M Esetup:931.43MB memory_limit:1024M tearDown:939.36MB memory_limit:1024M Esetup:939.39MB memory_limit:1024M tearDown:947.32MB memory_limit:1024M Esetup:947.35MB memory_limit:1024M tearDown:955.28MB memory_limit:1024M Esetup:955.31MB memory_limit:1024M tearDown:963.24MB memory_limit:1024M Esetup:963.27MB memory_limit:1024M tearDown:971.2MB memory_limit:1024M Esetup:971.23MB memory_limit:1024M tearDown:979.16MB memory_limit:1024M Esetup:979.26MB memory_limit:1024M tearDown:987.19MB memory_limit:1024M Esetup:987.22MB memory_limit:1024M tearDown:995.05MB memory_limit:1024M Esetup:995.07MB memory_limit:1024M tearDown:1003.01MB memory_limit:1024M Esetup:1003.03MB memory_limit:1024M tearDown:1010.97MB memory_limit:1024M PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 69632 bytes) in E:\wwwroot\object\config\us-zipcode.php on line 4 PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32768 bytes) in E:\wwwroot\object\vendor\symfony\debug\Exception\FatalErrorException.php on line 1 setup:1011MB memory_limit:1024M Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 69632 bytes) in E:\wwwroot\object\config\us-zipcode.php on line 4 Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32768 bytes) in E:\wwwroot\object\vendor\symfony\debug\Exception\FatalErrorException.php on line 1 PS E:\wwwroot\object>
2、编辑 php.ini 文件,设置 memory_limit = 4096M。之前为 memory_limit = 1024M。不会再次提示内存占用超限。
3、平时在运行测试用例的时候,一般不建议全部运行,参考使用说明:可以仅运行某个目录或者某个文件。以避免耗时过久与内存占用过高。如图2
PS E:\wwwroot\object> ./vendor/bin/phpunit -h PHPUnit 7.5.20 by Sebastian Bergmann and contributors. Usage: phpunit [options] UnitTest [UnitTest.php] phpunit [options] <directory>
4、仅运行某个目录:tests/Unit 与 仅运行某个文件:.\tests\Unit\ExampleTest.php。占用内存就很低了。如图3
PS E:\wwwroot\lighthouse-tutorial> ./vendor/bin/phpunit tests/Unit PHPUnit 9.5.11 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 00:00.008, Memory: 10.00 MB OK (1 test, 1 assertion) PS E:\wwwroot\lighthouse-tutorial> ./vendor/bin/phpunit .\tests\Unit\ExampleTest.php PHPUnit 9.5.11 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 00:00.008, Memory: 10.00 MB OK (1 test, 1 assertion)
近期评论