PHPCodeSniffer Task runs out of memory
|Reported by:||anonymous||Owned by:||mrook|
I'm working on an open source project with a relatively long history of people ignoring the coding standards, so I have a huge code base with many violations. So many violations, in fact, that with the project's custom coding style configuration Phing and PHPCodeSniffer consume all available memory shortly after reaching the halfway point of processing the code base (even using a long exclude list which excludes third party libraries and non-php files).
Looking at the code for the PHPCodeSniffer task, I think I've found the culprit. All warnings and errors are stored in memory until the run is finished and then copied and written to disk at the end of the run. Obviously, this doesn't scale well with project size. I'm using Jenkins to automate the runs and I've had to kill Phing because of memory exhaustion on a number of occasions. For example, in one instance I left the process to run over the weekend and it still hadn't completed after 60 hours, for a process that can take as little as an 1 hour when it's not running out of memory.
I can work around this by adding additional targets to Phing or reducing the number and variety of violations I check for. However, a permanent solution would be for Phing to periodically write the errors out to disk instead of keeping them all in memory until execution is finished. You might be tempted to think that it's a PHPCodeSniffer problem, but it looks like the output is actually being managed by Phing's PHPCodeSnifferTask.
Change History (4)
comment:1 Changed 6 years ago by mrook
- Component changed from phing-core to phing-tasks-ext
- Milestone changed from TBD to 2.4.7
- Priority changed from tbd to major
comment:3 Changed 5 years ago by mrook
- Milestone changed from 2.4.8 to TBD
- Status changed from new to infoneeded_new