Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very high memory usage and crash #18226

Closed
Pauan opened this issue Sep 3, 2017 · 3 comments
Closed

Very high memory usage and crash #18226

Pauan opened this issue Sep 3, 2017 · 3 comments
Labels
Fixed A PR has been merged for this issue

Comments

@Pauan
Copy link

Pauan commented Sep 3, 2017

TypeScript Version: 2.6.0-dev.20170902 (also happens on earlier versions)

I work at AmCharts, we have a fairly large code base written in TypeScript (~29,315 lines of code), but when compiling with tsc it consumes a few gigabytes of RAM and finally we get this error:

<--- Last few GCs --->

[24391:0x2c63610]    70596 ms: Mark-sweep 1401.0 (1535.3) -> 1401.0 (1535.3) MB, 1770.2 / 0.0 ms  allocation failure GC in old space requested
[24391:0x2c63610]    72459 ms: Mark-sweep 1401.0 (1535.3) -> 1401.0 (1505.3) MB, 1862.6 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1863 ms) last resort 
[24391:0x2c63610]    74312 ms: Mark-sweep 1401.0 (1505.3) -> 1401.0 (1505.3) MB, 1852.1 / 0.0 ms  last resort 


<--- JS stacktrace --->

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

Security context: 0x28731ee29891 <JS Object>
    2: findAncestor [amcharts4dev-0effa4a915dcea363716ff67c2bc2798eeb1d717/node_modules/typescript/lib/tsc.js:~284] [pc=0x38642953cd5f](this=0x24541b5fdfc1 <an Object with map 0x2b2aae5a411>,node=0x272f911b6331 <a Node with map 0x2b2aae4d891>,callback=0x1bd9ab9f80a1 <JS Function (SharedFunctionInfo 0x31ac7bec9ab1)>)
    3: isSymbolInScopeOfMappedTypeParameter(aka isSym...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x13647ec [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [node]
 6: v8::internal::DeoptimizationInputData::New(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
 7: v8::internal::LCodeGenBase::PopulateDeoptimizationData(v8::internal::Handle<v8::internal::Code>) [node]
 8: v8::internal::LChunk::Codegen() [node]
 9: v8::internal::HCompilationJob::FinalizeJobImpl() [node]
10: v8::internal::CompilationJob::FinalizeJob() [node]
11: 0xd9c4fa [node]
12: 0xd9cd42 [node]
13: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [node]
14: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [node]
15: 0x386428a8437d

This means we don't get any type checking at all, because it crashes with the above error before it finishes compiling. This is seriously hurting our development.

Our code doesn't do anything super crazy with the type system, just a lot of classes and interfaces. However, we do use one particular code pattern which seems to be particularly slow:

interface IFoo {
  foo: number;
}

class Foo {
  _interface: IFoo;

  foo(): this["_interface"] {
    ...
  }
}


interface IBar extends IFoo {
  bar: string;
}

class Bar extends Foo {
  _interface: IBar;
}

It's hard to create a self-contained example because the crash seems to only happen on large projects.

In addition, our code is private. How can I get our code to you so that you can figure out why it's crashing?

@Pauan
Copy link
Author

Pauan commented Sep 3, 2017

It might be related to #17968, but I'm not sure.

@ahejlsberg
Copy link
Member

@Pauan We just merged #18231 which I suspect will fix your issue. Can you give it a try with the next nightly build?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Sep 6, 2017
@Pauan
Copy link
Author

Pauan commented Sep 8, 2017

@ahejlsberg Yes, version 2.6.0-dev.20170906 fixes the crash, thank you very much!

@Pauan Pauan closed this as completed Sep 8, 2017
@ahejlsberg ahejlsberg added Fixed A PR has been merged for this issue and removed Needs More Info The issue still hasn't been fully clarified labels Sep 8, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants