Wing Ng
Wing Ng

Reputation: 11

METEOR/ FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory

I am working a project in meteor 0.9.2.2 and meteorite 0.9.2. I am trying to run my existing meteor app but, I've got an issue on stuck a long time on "Figuring out the best package versions to use. This may take a moment."

and finally got the following error:

FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory

/usr/local/lib/node_modules/meteorite/lib/command.js:41
throw "Command exited with " + code + "/" + signal;
^
Command exited with null/SIGABRT

I am wondering if there is any way to fix this error?

What ios memory is like when running meteor update:

memory screenshot

Upvotes: 1

Views: 876

Answers (2)

Theodore
Theodore

Reputation: 223

I'm adding this because I was having a similar problem, and I just managed to resolve it under meteor 1.4.3.1.

Background:

The issue is that meteor calls node to build. When it runs, node allocates a certain amount of memory for the V8 engine it runs on. In bigger projects, the default memory allocated for V8 is not sufficient to keep track of everything - it tried to garbage-collect as it gets closer to the limit, but eventually runs out of space and crashes with the error shown.

If we were just running node directly, we could run it with the --max-old-space-size option, which would allow us to set the maximum memory for the V8 engine. The issue is that meteor calls node in its own context and with its own options, so we can't just add the flag directly to our meteor call.

Solution:

It appears that meteor 1.4.3.1 (and maybe others) will pass along flags and options specified in the TOOL_NODE_FLAGS environment variable when it calls node (others have mentioned NODE_OPTIONS, but it isn't working for my version of meteor - the flags just get dropped)

So if you want to increase the max memory of the node engine to 4 GB, add an environmental variable:

TOOL_NODE_FLAGS="--max-old-space-size=4096" 

to the context you are running meteor in - the option should then be passed through to the node call.

(If you don't know where to set environment variables - it is usually going to be in your IDE build configuration or build script. If you want to sanity check if the option is actually being read, try changing it to gibberish - it should cause meteor to throw an error)

Upvotes: 0

Tarang
Tarang

Reputation: 75985

Meteor is quite heavy when it comes to using memory. Especially when it comes to installing packages and their dependencies.

As a general rule of thumb, make sure you have at least 1gb of RAM. If you have 512mb you may get stuck with problems like this.

This is a known issue with Meteor with no other workaround: https://github.com/meteor/meteor/issues/2475

Another option would be to increase your swap size.

Upvotes: 1

Related Questions