Skip to content

Node v4.2.6 - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memoryΒ #1868

Closed

Description

@busticated

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

Activity

  1. busticated commented on Feb 3, 2016

    @busticated
    Author

    more info: if i limit the number of test files - e.g.

    instead of:

        files: [
            'public/js/**/*.test.js'
        ]
    

    i use:

        files: [
            'public/js/util/*.test.js'
        ]
    

    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_size to 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 files tests across 87 files before hitting node's 1.7gb memory limit and falling over

  2. busticated commented on Feb 4, 2016

    @busticated
    Author

    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_size flag (whereas running using karma's CLI does not).

    var karma = fork('./karma-worker', {
        execArgv: ['--max_old_space_size=4096'] // increase v8's available memory to 4gb
    });
    
    karma.send({ type: 'start' /*, config: { ... } */});
    

    and then in the worker:

    process.on('message', function(msg){
        if (msg.type === 'start'){
            return new KarmaServer(config, done).start();
        }
    });
    
    function done(code){
        if (process.connected){
            process.send({ type: 'done', code: code });
        }
        process.exit(code);
    }
    

    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).

  3. dignifiedquire commented on Feb 4, 2016

    @dignifiedquire
    Member

    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 possibility

  4. busticated commented on Feb 4, 2016

    @busticated
    Author

    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.

    Β―_(ツ)_/Β―

  5. busticated commented on Feb 4, 2016

    @busticated
    Author

    @dignifiedquire thanks for taking a look.

    have you tried karma start -- --max_old_space_size=4096 ?

    yep, it doesn't work (same for setting it via config.client.args)

    I'd be happy to accept a PR that allows for that possibility

    i poked at that approach a bit but it seemed like a dead-end - in part b/c of this.

  6. dignifiedquire commented on Feb 4, 2016

    @dignifiedquire
    Member

    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 :/

  7. dignifiedquire commented on Feb 4, 2016

    @dignifiedquire
    Member

    Could you try reducing the amount of files/tests you are loading and see if there is a limit/specific file that triggers this?

  8. busticated commented on Feb 4, 2016

    @busticated
    Author

    @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 :)

  9. dignifiedquire commented on Feb 4, 2016

    @dignifiedquire
    Member

    What's the target file count? (test files and source files being loaded)

  10. busticated commented on Feb 4, 2016

    @busticated
    Author

    @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 (>_<)

  11. havenchyk commented on Jul 19, 2016

    @havenchyk

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

  12. ianks commented on Aug 12, 2016

    @ianks

    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:

    • uses karma-webpack
    • it is a react React application
    • uses typescript

    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?

  13. havenchyk commented on Aug 12, 2016

    @havenchyk

    @ianks what I did is, maybe it can be helpful

    • update babel to the latest version that supports passing params like max_old_space_size
    • set max_old_space_size
  14. teleaziz commented on Aug 12, 2016

    @teleaziz

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

  15. 19 remaining items

  16. jfcwagner commented on Mar 6, 2018

    @jfcwagner

    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!

  17. GalitTugi commented on Apr 22, 2018

    @GalitTugi

    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?

  18. nodkrot commented on Sep 15, 2018

    @nodkrot

    So is this going to be addressed?

  19. johnjbarton commented on Sep 18, 2018

    @johnjbarton
    Contributor

    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.

  20. nosus commented on Oct 19, 2018

    @nosus

    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.

  21. added a commit that references this issue on Mar 17, 2020
  22. added a commit that references this issue on Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions