karma: Node v4.2.6 - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

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:

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 14
  • Comments: 38 (11 by maintainers)

Commits related to this issue

Most upvoted comments

If others are having this issue still, I solved it buy using

node --max_old_space_size=4096 node_modules/karma/bin/karma start

instead of

karma start

Make sure karma is included in your project’s node_modules.

another workaround is:

  1. Create a test loader file: loadtests.js
  2. require all the tests in loadtests.js
const testsContext = require.context('./src', true, /\.spec\.js$/);
testsContext.keys().forEach(testsContext);
  1. Include loadtests.js in karma.conf.js
files: [
      'loadtests.js',
],
preprocessors: {
      'loadtests.js': ['webpack', 'coverage'],
},

I found that with a growing number of tests, this was a problem even though I allocated more memory with the flag --max_old_space_size=4096

karma start karma.conf.js --max_old_space_size=4096

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Removing source mapping as defined here: https://webpack.github.io/docs/usage-with-karma.html#source-maps helped get over this

karma.conf.js

webpack: { // devtool: ‘inline-source-map’,

Good luck out there!

I used --max_old_space_size and I again got the memory error. After doing some online research i realized it not underscore but dash like --max-old-space-size

When using gulp this works fine:

> node --max_old_space_size=4096 node_modules/.bin/gulp task

@ianks just wondering if this is related to karma-sourcemap-loader plugin? same setup except it’s angular 2 project with TS

to avoid the above comments confuse people in the future karma start karma.conf.js --max_old_space_size=4096 does NOT work and node --max_old_space_size=4096 node_modules/karma/bin/karma start works

At least for me.

@stevemao’s solution is the only one that worked for me. Setting max_old_space_size to 4096 did not help (we have about 1500 tests).

@dignifiedquire do you need any additional info? I faced the same issue