Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor Out of Memory

I'm using meteor to make scrapping engine and I have to do a HTTP GET request and this send me an xml but this xml is bigger than 400 ko.

I get a exception "out of memory".

result =Meteor.http.get 'http://SomeUrl.com'

FATAL ERROR: JS Allocation failed - process out of memory

There is a way to increase memory limit of a variable ?

like image 841
Z. Clément Avatar asked Sep 06 '15 09:09

Z. Clément


6 Answers

I'm developing on Windows and had the same error. In my case, was caused by a flood of console.log statements. I disabled the log statements, and works fine again.

like image 140
Lucidity Avatar answered Oct 18 '22 02:10

Lucidity


if you are Developing on windows

find meteor.bat in /APPData/Local/.meteor/packages/meteor-tool/<build-tool-version>/

edit the last line of the batch file which calls the node.exe and change to

"%~dp0\dev_bundle\bin\node.exe" --max-old-space-size=2048 "%~dp0\tools\main.js" %*

Hope this helps

like image 25
gatolgaj Avatar answered Oct 18 '22 04:10

gatolgaj


Same here on Windows 10 using Meteor 1.1.0.3:

C:\Users\Cees.Timmerman\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tools\fiber-helpers.js:162
    }).run();
       ^
FATAL ERROR: Evacuation Allocation failed - process out of memory

Resolved by setting console log level to "warning" instead of "debug" in settings.json used internally by a logger package like Winston 2.1.0 (var level = Meteor.settings.log_level).

like image 43
Cees Timmerman Avatar answered Oct 18 '22 03:10

Cees Timmerman


It is possible to increase the memory available to your node application that is spawned using meteor.

I did not have success using the --max-old-space-size flag in the instance of node called in the meteor script nor in trying to change that in the script in meteor-tool as suggested by gatolgaj

However setting the environment variable NODE_OPTIONS="--max-old-space-size=8192" did work for me.

I saw it mentioned in this thread: https://groups.google.com/forum/#!topic/meteor-talk/C5oVNqm16MY

like image 26
tarrow Avatar answered Oct 18 '22 02:10

tarrow


You need to increase the amount of memory on your server, e.g. by enabling swap memory. To see how, assuming you're on Linux, you can f.ex. read DigitalOcean's guide on enabling swap memory on Ubuntu 14.04.

I don't know of any way to handle the case where Node runs out of memory, except perhaps you could separate the GET request into a child process so that the whole server doesn't crash in case you run out of memory.

To increase Node's memory limit, you could use Node's --max_old_space_size option.

like image 38
aknuds1 Avatar answered Oct 18 '22 03:10

aknuds1


I know this question is solved and a bit old, but I would like to share my experience. After some research, I just updated my Meteor version. It seems they are recently taking more care about Out Of Memory Errors. So I will encourage you to update to new Meteor versions.

like image 28
alonso_50 Avatar answered Oct 18 '22 04:10

alonso_50