phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Test runner being "Killed" during post-test summary

Open EvanK opened this issue 14 years ago • 8 comments

When running a test suite for a specific large project of 1000+ tests (and at least twice as many assertions), the tests themselves run just fine. However, any tests failing causes a huge memory usage spike during the post-test summary. This spike is so drastic that the phpunit process is killed by Linux's OOM killer as a result:

PHPUnit 3.6.7 by Sebastian Bergmann.

.............................................................   61 / 1044 (  5%)
.............................................................  122 / 1044 ( 11%)
.............................................................  183 / 1044 ( 17%)
.............................................................  244 / 1044 ( 23%)
.............................................................  305 / 1044 ( 29%)
.............................................................  366 / 1044 ( 35%)
.............................................................  427 / 1044 ( 40%)
.............................................................  488 / 1044 ( 46%)
.............................................................  549 / 1044 ( 52%)
.............................................................  610 / 1044 ( 58%)
.............................................................  671 / 1044 ( 64%)
.............................................................  732 / 1044 ( 70%)
.............................................................  793 / 1044 ( 75%)
.............................................................  854 / 1044 ( 81%)
........................................................F....  915 / 1044 ( 87%)
.............................................................  976 / 1044 ( 93%)
............................................................. 1037 / 1044 ( 99%)
.......

Time: 01:36, Memory: 113.25Mb

There was 1 failure:
Killed

Any idea what's causing this, or how to work around it?

EvanK avatar Feb 05 '12 03:02 EvanK

My first guess would have been "code coverage generation" as I've seen +4k tests with +10k assertions easily consume 3GB of memory and my suggestion would have been to clean up as much as possible in tearDown and see if that helps.

But in your case it seems like you don't generate code coverage reports so I'm mostly guessing here.

It'd say it's ether memory usage or the garbage collection running wild. With 5.2.x it was, for me, common for PHP to segfault once PHPUnit runs got very big but with current versions I didn't run into this.

How does your failing test look like?

If you compair two 2GB strings and PHPUnit is trying to diff them (or something like that) that would explain that.

edorian avatar Feb 05 '12 09:02 edorian

Regardless of whether or not that is the issue here, maybe we should add limits to diff generation?

sebastianbergmann avatar Feb 05 '12 09:02 sebastianbergmann

EvanK: why did you close issue ? TYIA

jpic avatar Feb 14 '12 08:02 jpic

Sorry, I didn't mean to close w/o comment. The team lead on our project narrowed it down to one particular test that causes this spike in resource usage even if it's the only test ran. Said test is extending Symfony2's WebTestCase, so I suspect the problem lies there, somewhere...

EvanK avatar Feb 14 '12 16:02 EvanK

Is this issue solved? I have the same problem. Please help.

feridmovsumov avatar Jan 31 '14 12:01 feridmovsumov

My syslog result,

Jan 31 15:42:06 adem kernel: [ 6260.784323] Out of memory: Kill process 5558 (phpunit) score 852 or sacrifice child Jan 31 15:42:06 adem kernel: [ 6260.784325] Killed process 5558 (phpunit) total-vm:14206088kB, anon-rss:7054836kB, file-rss:1656kB

adem-oztas avatar Jan 31 '14 13:01 adem-oztas

Same for me here except my tests get 'Killed' in the process of testing. Running the killed test separately passes ok. Increasing memory does not help.

dmitrybelyakov avatar May 17 '14 09:05 dmitrybelyakov

This can happen when you're var_dumping something in code

hugronaphor avatar Jun 16 '22 16:06 hugronaphor