问题
I'm currently using Zend Framework in conjunction with PHPUnit to conduct unit testing on an application. When Hudson executes the PHPUnit shell command, the maximum PHP memory limit is reached sometime during code coverage generation. I currently have a total of 41 tests with 334 assertions.
I have successfully eliminated this error by raising the memory_limit setting to 768M using the -d memory_limit=768M
switch; however, I am worried that as the complexity increases along with the total number of tests/assertions, I will not have enough memory to generate the HTML for code coverage statistics.
OS: CentOS 5.5
Control Panel: WHM/cPanel
CI Server: Hudson
/usr/local/bin/phpunit
--verbose
-d memory_limit=512M
--log-junit ../../build/logs/phpunit.xml
--coverage-clover ../../build/logs/coverage/clover.xml
--coverage-html ../../build/logs/coverage-html/
Fatal error: Allowed memory size of 536870912 bytes exhausted
Before committing my changes and letting Hudson handle the rest, I use Windows 7 for development. The memory usage never exceeded 340MB while running the same command within W7.
回答1:
By reducing the number of files included within code coverage, as well as increasing the overall memory limit in PHP, I was able to basically kill this error. The entire Zend Framework was being included within code coverage, which is very large.
回答2:
Do you have xdebug profiling enabled, if so try disabling it. I've experienced this problem before, and it came down to extensions in php (specifically xdebug profiling and/or Inclued heirarchy viewer)
来源:https://stackoverflow.com/questions/3895038/phpunit-code-coverage-generation-causing-memory-exhaustion