Repository navigation
Closed
Labels
Description
hey there -
i'm hitting the following error after upgrading to node v4 LTS.
02 02 2016 11:13:08.092:INFO [karma]: Karma v0.13.19 server started at http://localhost:9876/
02 02 2016 11:13:08.122:INFO [launcher]: Starting browser PhantomJS
<--- Last few GCs --->
22555 ms: Scavenge 1441.4 (1502.2) -> 1441.4 (1502.2) MB, 1.6 / 0 ms (+ 2.4 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
22610 ms: Mark-sweep 1441.4 (1502.2) -> 1441.2 (1502.2) MB, 55.5 / 0 ms (+ 3.6 ms in 2 steps since start of marking, biggest step 2.4 ms) [last resort gc].
22664 ms: Mark-sweep 1441.2 (1502.2) -> 1441.2 (1502.2) MB, 54.0 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x3acf8b8b4629 <JS Object>
1: exec [native regexp.js:~85] [pc=0x1ab48201d158] (this=0x3477de668ed1 <JS RegExp>,k=0x1dc821cffa39 <String[106]: Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1>)
2: parse [/path/to/my/project/node_modules/karma/node_modules/useragent/index.js:427] [pc=0x1ab4821e1cbf] (this=0x276f61054869 <JS Funct...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Abort trap: 6`
Likewise, i see a similar error when running tests in chrome:
>>karma start
02 02 2016 11:49:26.366:WARN [karma]: No captured browser, open http://localhost:9876/
02 02 2016 11:49:26.447:INFO [karma]: Karma v0.13.19 server started at http://localhost:9876/
02 02 2016 11:49:26.455:INFO [launcher]: Starting browser Chrome
<--- Last few GCs --->
21051 ms: Mark-sweep 1429.9 (1488.2) -> 1429.4 (1488.2) MB, 26.3 / 0 ms (+ 124.4 ms in 20 steps since start of marking, biggest step 82.2 ms) [allocation failure] [GC in old space requested].
21163 ms: Mark-sweep 1429.4 (1488.2) -> 1429.4 (1488.2) MB, 110.6 / 0 ms [last resort gc].
21298 ms: Mark-sweep 1429.4 (1488.2) -> 1429.3 (1488.2) MB, 135.5 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x24bd825b4629 <JS Object>
2: decodeURIComponent(aka decodeURIComponent) [native uri.js:248] [pc=0x2575a442da41] (this=0x24bd825041b9 <undefined>,W=0x111d0ab40cd9 <String[2]: id>)
3: /* anonymous */(aka /* anonymous */) [querystring.js:83] [pc=0x2575a4426aee] (this=0x24bd825041b9 <undefined>,s=0x111d0ab40cd9 <String[2]: id>,decodeSpaces=0x24bd825041b9 <undefined>)
4: arguments adaptor frame: 1->2
5: decod...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Abort trap: 6
My environment:
- node: v4.2.6
- phantomjs: v1.9.8
- karma: v0.13.19
- karma-phantomjs-launcher: v0.2.3
- karma-chrome-launcher: v0.2.2
- karma-chai: v0.1.0
- karma-mocha: v0.2.1
- karma-sinon: v1.0.4
- karma-sourcemap-loader: v0.3.7
- karma-webpack: v1.7.0
- webpack: v1.12.12
I tried updating to the latest phantomjs but the error persisted - upgrades:
- phantomjs phantomjs-prebuilt: v2.1.1
- karma-phantomjs-launcher: v1.0.0
Running under the old configuration works fine:
- node: v0.10.41
- phantomjs: v1.9.8
- karma: v0.13.19
- karma-phantomjs-launcher: v0.2.3
- karma-chrome-launcher: v0.2.2
- karma-chai: v0.1.0
- karma-mocha: v0.2.1
- karma-sinon: v1.0.4
- karma-sourcemap-loader: v0.3.7
- karma-webpack: v1.7.0
- webpack: v1.12.12
I'm on os-x v10.10.5
Reacted by Ian Ker-Seymer, Aziz Abbas, Jakob Hohlfeld, Brian M Hunt, Igor Sukach, MichaΕ CzapliΕski, Steve Mao, Eugenio Romano, Marc Bennewitz, Piper and 4 more
Activity
busticated commentedon Feb 3, 2016
more info: if i limit the number of test files - e.g.
instead of:
i use:
both chrome and phantomjs run the reduced test suite fine. not headline news i realize but still :-D
is there a way to set the V8 option
--max_old_space_sizeto increase the max memory limit of the karma process? i'm not seeing anything obvious in the docs.edit: fwiw, looks like i can run ~800
filestests across 87 files before hitting node's 1.7gb memory limit and falling overbusticated commentedon Feb 4, 2016
fwiw, my work-around is to run karma as a child process using the public api - this allows me to set the
--max_old_space_sizeflag (whereas running using karma's CLI does not).and then in the worker:
there's some additional fiddly bits around error / disconnect handling, etc but this is the basic gist. only thing i'm missing at the moment is colored output - for whatever reason the only messages that retain their color (green) are 'karma started', 'starting browser', and 'connected' messages (the first 3 you typically see during a run).
dignifiedquire commentedon Feb 4, 2016
I'm not sure but have you tried
karma start -- --max_old_space_size=4096? If not I'd be happy to accept a PR that allows for that possibilitybusticated commentedon Feb 4, 2016
re: memory consumption - comparing node v4 LTS to v0.10.41 i see similar memory use. v0.10.41 maxes out at ~1.9gb, node v4 at ~2.3gb. in both cases, that seems really high to me (as a reference point, my build task - LESS & webpack - uses ~100mb of memory). the really weird thing is that v4 crashes but v0.10 does not yet my understanding is that both use the same default memory limit.
Β―_(γ)_/Β―
busticated commentedon Feb 4, 2016
@dignifiedquire thanks for taking a look.
yep, it doesn't work (same for setting it via config.client.args)
i poked at that approach a bit but it seemed like a dead-end - in part b/c of this.
dignifiedquire commentedon Feb 4, 2016
A lot of things have changed in the v8 versions between 0.10 and 4.0 so it might be that sth there is the result of the crashing in one point and working fine in the other.
From the file count these limits should never be reached (I've run karma on larger projects, e.g. take a look at the angular main source) so it seems to be that there is probably some memory leak/bug why this is happening :/
dignifiedquire commentedon Feb 4, 2016
Could you try reducing the amount of files/tests you are loading and see if there is a limit/specific file that triggers this?
busticated commentedon Feb 4, 2016
@dignifiedquire yep, can do. buried in my note above --> i can run ~800 files tests across 87 files before hitting the limit and crashing. that was just a quick try though. i'll be more deliberate and see what i see :)
dignifiedquire commentedon Feb 4, 2016
What's the target file count? (test files and source files being loaded)
busticated commentedon Feb 4, 2016
@dignifiedquire just looking at chrome's network tab while running in the debug view, i see 232 files / 458mb(!). this includes helpers like chai.js, mocha.js, etc but is mostly local source. (NOTE: this is while running to completion w/
--max_old_space_size=4096)it's not uncommon to see individual test files > 4mb since these are built by webpack and include external dependencies (e.g. react, etc) as well as sourcemaps. that certainly seems like something i can tune a bit better - maybe by loading common deps in a single file or something.
edit: like this (>_<)
havenchyk commentedon Jul 19, 2016
@dignifiedquire do you need any additional info? I faced the same issue
ianks commentedon Aug 12, 2016
This issue is also coming up with me. I can confirm that karma is using ~1600Mb of virtual memory and ~600Mb of actual memory.
Some notes about my config:
I attempted to take some heap snapshots of karma using node-inspector, and noticed that when I would attempt to snapshot the heap for when I was testing my React components, i would trigger the
Allocation failed - process out of memory, which left me unable to get the final results of the snapshot πDoes anyone have any pointers about further debugging this issue?
havenchyk commentedon Aug 12, 2016
@ianks what I did is, maybe it can be helpful
teleaziz commentedon Aug 12, 2016
@ianks just wondering if this is related to karma-sourcemap-loader plugin? same setup except it's angular 2 project with TS
19 remaining items
jfcwagner commentedon Mar 6, 2018
Agree with @epernice. @stevemao's solution worked for me, too. My team and I have been dealing with this problem on and off for months. Thanks @epernice for calling it out; thanks @stevemao for the workaround!
GalitTugi commentedon Apr 22, 2018
Happened to me too, and found out that caused by webpack's
EvalSourceMapDevToolPlugin (aso happened with SourceMapDevToolPlugin).
I need this plugin for debugging, did anybody else handle this situation?
nodkrot commentedon Sep 15, 2018
So is this going to be addressed?
johnjbarton commentedon Sep 18, 2018
Based on all of the information posted here, the issue is not something karma-runner can fix. The runner itself is not causing memory overflow but some combination of webpack and sourcemaps. It looks like @stevemao has a workaround.
nosus commentedon Oct 19, 2018
to avoid the above comments confuse people in the future
karma start karma.conf.js --max_old_space_size=4096does NOT workand
node --max_old_space_size=4096 node_modules/karma/bin/karma startworksAt least for me.
Improve karma conf in order to find solution for test run crashing
ui: Fix OOM exception while building tests
Merge #46047 #46132 #46179
Merge #46640