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

TypeScript Version: nightly (2.6.0-dev.20170912)

Code

{
  "compilerOptions": {
    "module": "system",
    "jsx": "react",
    "target": "es5",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "newLine": "lf",
    "allowJs": false,
    "noImplicitAny": true,
    "baseUrl": "./",
    "noEmitOnError": true,
    "sourceMap": true,
    "alwaysStrict": true,
    "inlineSourceMap": false,
    "paths": {
      "*": [
        "node_modules/@types/*"
      ]
    },
    "lib": [
      "dom",
      "es2015",
      "es5"
    ]
  }
}
07:28:49 - File change detected. Starting incremental compilation...



<--- Last few GCs --->

[1592:000002842FE68000]  7027823 ms: Mark-sweep 1401.5 (1465.4) -> 1401.5 (1465.4) MB, 4599.6 / 0.0 ms  last resort


<--- JS stacktrace --->

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

Security context: 0000033CF2C1CEA9 <JSObject>
    1: set [native collection.js:~247] [pc=000000C2A8FE6697](this=000000F425FBE6F1 <Map map = 000003AA6FD983B9>,p=000003A9ED17AB21
<String[9]: @Telefone>,x=000003A9ED17AB51 <Type map = 000003AA6FDC6CF9>)
    2: getLiteralType(aka getLiteralType) [C:\nodejs\node_modules\typescript\lib\tsc.js:~24883] [pc=000000C2A8D93E76](this=0000033C
F2C02241 <undefined>,value=000000CEC1A9C961 <String[8]: Telef...

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

Expected behavior:

Not crash

Actual behavior:

TS in watch mode is randomly crashing with the above stacktrace. I can’t figure out what is making it crash. I’m using vscode, but the watch mode is tsc -w -p tsconfig.json

per @sandersn recommendation (in https://github.com/Microsoft/TypeScript/issues/17112#issuecomment-328902121) opening a new issue about the same error name, but different stack

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 43 (19 by maintainers)

Most upvoted comments

@pocesar Wanted to make sure you are using the latest build. While i tried to repro this on larger code base, I noticed that in --diagnostics mode there is too much logging on the command line. Did you notice that? (The fix for that would be in PR #18970). Also I did not see explosion in memory. The memory usage is more than previous version but memory isn’t leaking and is being collected. Ex here are the memory numbers I saw on few larger code bases:

Synchronizing program

Files:          5010
Lines:        302718
Nodes:       1124917
Identifiers:  358857
Symbols:      449513
Types:        128493
Memory used: 885844K
I/O read:      0.68s
I/O write:     7.36s
Parse time:   18.20s
Bind time:     1.14s
Check time:   10.79s
Emit time:    13.72s
Total time:   43.85s
11:43:57 - Compilation complete. Watching for file changes.

Files:          5010
Lines:        302718
Nodes:       1124925
Identifiers:  358859
Symbols:      182359
Types:           543
Memory used: 888615K
I/O read:      0.00s
I/O write:     0.00s
Parse time:    0.34s
Bind time:     0.01s
Check time:    0.12s
Emit time:     0.06s
Total time:    0.52s
11:45:00 - Compilation complete. Watching for file changes.

Files:          5010
Lines:        302718
Nodes:       1124917
Identifiers:  358857
Symbols:      182358
Types:           541
Memory used: 889869K
I/O read:      0.00s
I/O write:     0.00s
Parse time:    0.28s
Bind time:     0.01s
Check time:    0.03s
Emit time:     0.04s
Total time:    0.36s
11:45:26 - Compilation complete. Watching for file changes.

Files:          5010
Lines:        302718
Nodes:       1124921
Identifiers:  358858
Symbols:      182361
Types:           545
Memory used: 633818K
I/O read:      0.00s
I/O write:     0.00s
Parse time:    0.24s
Bind time:     0.01s
Check time:    0.03s
Emit time:     0.05s
Total time:    0.33s
11:46:38 - Compilation complete. Watching for file changes.

--strict in 2.6 adds a new --strictFunctionTypes, setting this to false should return you to the 2.5.3 --strict behavior.

should I stop reporting the same behavior on nightlies until #17269 gets merged?

yes please.

Same error here .