Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit code coverage generation causing memory exhaustion

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.

like image 891
webjawns.com Avatar asked Oct 08 '10 23:10

webjawns.com


1 Answers

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.

like image 93
webjawns.com Avatar answered Sep 23 '22 09:09

webjawns.com