Skip to content

Javascript out of memory in watch mode #6147

@GoGoris

Description

@GoGoris

🐛 Bug Report

After running watch mode for approximately an hour, I got an out of memory from node.
Could this be related to Jest?

<--- Last few GCs --->

[5740:00000241ACC6B090]  3179303 ms: Mark-sweep 1372.1 (1434.3) -> 1372.0 (1435.3) MB, 1106.6 / 0.2 ms  allocation failure GC in old space requested
[5740:00000241ACC6B090]  3180427 ms: Mark-sweep 1372.0 (1435.3) -> 1371.6 (1420.3) MB, 1124.4 / 0.3 ms  last resort GC in old space requested
[5740:00000241ACC6B090]  3181596 ms: Mark-sweep 1371.6 (1420.3) -> 1371.6 (1420.3) MB, 1169.0 / 0.3 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0000019E5C5257C1 <JSObject>
    1: stringSlice(aka stringSlice) [buffer.js:560] [bytecode=000001CCABEE4D11 offset=94](this=0000014081D822D1 <undefined>,buf=00000307478D8101 <Uint8Array m
ap = 00000354C1CC3231>,encoding=0000019E5C534EB1 <String[4]: utf8>,start=0,end=2233034)
    2: toString [buffer.js:633] [bytecode=000001CCABEE4961 offset=145](this=00000307478D8101 <Uint8Array map = 00000354C1CC3231>,encoding=0000019E5C53...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node_module_register
 2: v8::internal::FatalProcessOutOfMemory
 3: v8::internal::FatalProcessOutOfMemory
 4: v8::internal::Factory::NewRawTwoByteString
 5: v8::internal::Factory::NewStringFromUtf8
 6: v8::String::NewFromUtf8
 7: v8_inspector::V8InspectorClient::currentTimeMS
 8: node::Buffer::New
 9: v8::internal::wasm::SignatureMap::Find
10: v8::internal::Builtins::CallableFor
11: v8::internal::Builtins::CallableFor
12: v8::internal::Builtins::CallableFor
13: 00000052852043C1

To Reproduce

Because the project is not very large, the effect is not as pronounced as in other projects.
In our production test suite we have 44 angular tests that trigger an out of memory after 3 runs (1331MB). However it does show that the heap size grows after each test run:

Log growing heapsize

  1. Checkout https://github.com/ngrx/platform
  2. yarn run jest --runInBand --logHeapUsage --watchAll
  3. Modify a character in a testfile to trigger another test run, the heapsize will keep on growing

Detect leaks

  1. Add a dependency on weak in order to run --detectLeaks: yarn add --dev weak
  2. yarn run jest --detectLeaks

Run npx envinfo --preset jest

Paste the results here:

npx: installed 1 in 2.138s
%USERPROFILE%\AppData\Roaming\npm-cache\_npx\1340\node_modules\envinfo\dist\cli.js

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
  Binaries:
    Yarn: 1.5.1 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.0.0 - C:\Program Files\nodejs\npm.CMD

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