TypeScript: Out of memory
Search Terms: high memory usage heap react
Code
export type ScheduleProps = {
// ...
eventContentComponent?: React.ElementType<EventContentProps>;
eventRootComponent?: React.ElementType<EventRootProps>;
};
Expected behavior: Compiled.
Actual behavior:
$ tsc --project . --noEmit
<--- Last few GCs --->
[15840:0x2897f30] 25267 ms: Mark-sweep 1335.2 (1446.8) -> 1327.9 (1449.3) MB, 938.0 / 0.0 ms (average mu = 0.195, current mu = 0.058) allocation failure scavenge might not succeed
[15840:0x2897f30] 26971 ms: Mark-sweep 1339.7 (1449.3) -> 1332.1 (1450.8) MB, 1650.9 / 0.0 ms (average mu = 0.096, current mu = 0.031) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x38acc9bdbe1d]
1: StubFrame [pc: 0x38acc9ba236e]
Security context: 0x23118b41e6e1 <JSObject>
2: slice [0x23118b406d09](this=0x26806be58fb9 <JSArray[12]>,0)
3: /* anonymous */(aka /* anonymous */) [0x367b1a96a1f9] [/home/f/Projects/remotelock/react-week-scheduler/node_modules/typescript/lib/tsc.js:~32894] [pc=0x38acca56d751](this=0x2aaba17826f1 <undefined>,t=0x0e1171e59ff9 <Type map = 0x12d8538d48a1>)
Repo: https://github.com/remotelock/react-week-scheduler
Steps to reproduce:
- Clone repo
git checkout 9c64f4f7224d199d9706c4fdec4cd073292c1842yarnyarn check-ts
Replacing React.ElementType here (L25 & 27) with any works around the bug.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 15 (6 by maintainers)
Experiencing the same issue. Any updates / solutions / recommendations?
I think would be great if TypeScript can figure out the possible locations in the code that cause this out of memory problem. It’s really hard to pinpoint…
Ran into same problem as @panjiesw. Also importing utility types and the like from many projects. It would just continuously climb no matter what. Turning off incremental compilation fixed it.
EDIT: Using create-react-app, so changing
fork-ts-checker-webpack-plugin’s option usingrescriptsvia:was needed after the command line tsc no longer ran out of memory.
I did some debugging on the compiler and it seemed get stuck in an infinite loop on the
DeepReadonly/DeepPartialutility types ofts-essentialspackage while incremental was turned on.The original example no longer OOMs on latest TS. If you have a new, self-contained example on latest TS, please open a new issue to let us know. ❤️
I encountered this in a project part of somewhat big monorepo. It’s also a React library project, but I don’t know if it’s the same cause as the HOCs issue because this particular project doesn’t export React component. It does import many types and utility types from 3rd party libraries.
I was trying
tscbuild mode combined with--incremental. It works previously since TS v3.1Anyway, even after setting
"strict": false, I still got Out of memory errorThe
tscCLI stopped at1.4GBRAM consumption as seen in the log. This also made VSCode eats a lot of RAM, topping at around2.1GB, but it eventually settled down, probably that’s the amount of RAM needed to parse the project.Same root cause as #29949. Turning off
strictFunctionTypesshould be another blanket workaround until we can fix these comparisons for properties of HOCs to be more efficient.