Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Crashing with out of memory exception #227

Closed
mvestergaard opened this issue Sep 7, 2016 · 14 comments
Closed

Crashing with out of memory exception #227

mvestergaard opened this issue Sep 7, 2016 · 14 comments

Comments

@mvestergaard
Copy link

I'm having a tough time figuring out exactly what/why/when caused this exception to start happening, but I seem to have narrowed it down to only happening after v2.2.1

When running through a webpack dev server and making changes, after a while the process crashes with this exception:

Error: channel closed
    at ChildProcess.target.send (internal/child_process.js:540:16)
    at runChecker (/Users/mv/dev/js/product-designer/node_modules/awesome-typescript-loader/src/instance.ts:388:22)
    at invokeFunc (/Users/mv/dev/js/product-designer/node_modules/lodash/lodash.js:10024:23)
    at trailingEdge (/Users/mv/dev/js/product-designer/node_modules/lodash/lodash.js:10071:18)
    at Timeout.timerExpired [as _onTimeout] (/Users/mv/dev/js/product-designer/node_modules/lodash/lodash.js:10059:18)
    at tryOnTimeout (timers.js:232:11)
    at Timer.listOnTimeout (timers.js:202:5)

Some of the time it is preceded by this error:

<--- Last few GCs --->

   43983 ms: Mark-sweep 1311.1 (1433.0) -> 1310.9 (1440.0) MB, 1450.2 / 0.0 ms [allocation failure] [GC in old space requested].
   45501 ms: Mark-sweep 1310.9 (1440.0) -> 1310.9 (1440.0) MB, 1518.8 / 0.0 ms [allocation failure] [GC in old space requested].
   47004 ms: Mark-sweep 1310.9 (1440.0) -> 1321.6 (1409.0) MB, 1501.7 / 0.0 ms [last resort gc].
   48543 ms: Mark-sweep 1321.6 (1409.0) -> 1332.6 (1409.0) MB, 1539.4 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 0x1ed0af3cfb51 <JS Object>
    1: createTypeReference [/Users/mv/dev/js/product-designer/node_modules/typescript/lib/typescript.js:~20534] [pc=0x1f1beb71ebba] (this=0x1ed0af3e6ee9 <JS Global Object>,target=0xaf18ff9b3a9 <a TypeObject with map 0x1b5c8ee7baf9>,typeArguments=0xf402c4ae0b1 <JS Array[1]>)
    2: instantiateType [/Users/mv/dev/js/product-designer/node_modules/typescript/lib/typescript.js:~21234] [pc=0x1f1beb09...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/iojs]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/iojs]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/iojs]
 4: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/usr/local/bin/iojs]
 5: v8::internal::HashTable<v8::internal::SeededNumberDictionary, v8::internal::SeededNumberDictionaryShape, unsigned int>::EnsureCapacity(v8::internal::Handle<v8::internal::SeededNumberDictionary>, int, unsigned int, v8::internal::PretenureFlag) [/usr/local/bin/iojs]
 6: v8::internal::SeededNumberDictionary::AddNumberEntry(v8::internal::Handle<v8::internal::SeededNumberDictionary>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDetails, bool) [/usr/local/bin/iojs]
 7: v8::internal::(anonymous namespace)::DictionaryElementsAccessor::AddImpl(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, unsigned int) [/usr/local/bin/iojs]
 8: v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [/usr/local/bin/iojs]
 9: v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode) [/usr/local/bin/iojs]
10: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/iojs]
11: 0x1f1be94092a7

node: v6.5.0
webpack: 2.1.0-beta.20
typescript: tried both 2.0 and 2.0.2
os: OSX

Using versions of ATL prior to 2.2.1 does not seem to cause this error, however they do result in compile time errors due to improper support of @types, so the fact that the tsc compile fails may be what prevents this from happening, can't say for sure. What i'm doing to provoke the error is to edit the same file over and over again, so maybe it's because the type checking does not get a chance to complete before making another change, and triggering a new build?

I've tried disabling the ForkChecker plugin with same result.

@s-panferov
Copy link
Owner

s-panferov commented Sep 7, 2016

@mvestergaard does your project compiles properly with ts-loader or plain tsc? I believe that it's an error in TypeScript itself.

@thrandre
Copy link

thrandre commented Sep 7, 2016

I'm experiencing the same issue on versions > 2.21. Initial build times have increased dramatically.

node: v6.5.0
webpack: 2.1.0-beta.20
typescript: tried both 2.0 and 2.0.2
os: Windows 10

tsc works as expected.

@mvestergaard
Copy link
Author

tsc works fine, have not been able to try ts-loader since that does not support @types properly.

@s-panferov
Copy link
Owner

Could you plz give me some example to reproduce?

@mvestergaard
Copy link
Author

It's a closed source app for my work, but i suppose you can try it since its so early in development.

https://github.com/mvestergaard/product-designer

npm install && typings install

Then npm start to start it.

Edit one of the react files or something over and over until it crashes.

@mvestergaard
Copy link
Author

It actually only seems to take one change. You just have to wait long enough. This seems to be some sort of memory leak issue.

After the initial build, one of the build processes sits at 1,06GB memory.

screen shot 2016-09-07 at 11 29 53

After a single change the memory clims to 1,4GB memory and eventually crashes.
screen shot 2016-09-07 at 11 31 27

@s-panferov
Copy link
Owner

I've cloned the repo, thx. You can hide it back.

@s-panferov
Copy link
Owner

Everything compiles good at my Mac, maybe it's some Windows-related issue again. I'll try to debug.

@mvestergaard
Copy link
Author

I'm on mac as well though. Initial compilation is not the issue, try making a change somewhere afterwards so the process rebuilds, and take a look at the memory usage of the build process.

@s-panferov
Copy link
Owner

@mvestergaard yes, I see now. Ok, I'll try to solve this

@mvestergaard
Copy link
Author

ATL is probably not entirely to blame for this. Running a normal tsc also eats up alot of memory. It rises to around 1.1GB before compilation ends.

I can imagine ATL needs to clean up better between runs, so it doesn't exceed the memory limit, but I can imagine a project large enough could cause tsc to crash on its own.

@guncha
Copy link
Contributor

guncha commented Sep 19, 2016

I'm seeing the same issue. I have forkChecker configured and I can watch the spawned process take off until it hits the Node's memory limit and is killed. Doing a tsc --noEmit on the project uses a ton of memory too (1.2 GB), but slightly less to kill the process.

Btw, @s-panferov, is there any way to configure the spawned process to use a different limit via --max_old_space_size as a temporary workaround?

@mvestergaard
Copy link
Author

mvestergaard commented Sep 19, 2016

It seems to be an issue with typescript itself caused by something in the enzyme typings, see linked issue above.

@zspecza
Copy link
Contributor

zspecza commented Dec 10, 2016

This seems related with #287

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants