7

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 ?

Z. Clément
  • 474
  • 4
  • 15

6 Answers6

3

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

gatolgaj
  • 1,193
  • 7
  • 12
  • The above didn't help me on Meteor 1.2. I found another solution, but looks really close if someone's has to solve it this way! Note: In Meteor 1.2 you're calling \tools\index.js not \tools\main.js – Lucidity Oct 16 '15 at 10:26
3

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.

Lucidity
  • 1,299
  • 17
  • 19
  • Sorry my late reply, it was the same in fact for me on Linux and lot of time is caused by a too big log output. – Z. Clément Oct 29 '15 at 03:11
  • I never would have thought of trying this, but it did the trick! (Meteor 1.2.1 on Windows) – Kiv Dec 08 '15 at 03:01
3

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

tarrow
  • 31
  • 3
2

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.

aknuds1
  • 65,625
  • 67
  • 195
  • 317
  • Thanks to reply. But my swap is already enable. And I have 4gB of memory so I think I get it because meteor use node and node have a memory limit. – Z. Clément Sep 06 '15 at 09:46
  • @Logoosse Have you tried setting [--max-old-space-size](http://stackoverflow.com/questions/7193959/memory-limit-in-node-js-and-chrome-v8) in order to increase the amount of available memory? I wasn't aware of this setting myself until now. – aknuds1 Sep 06 '15 at 09:51
  • I did it, but meteor is not node.js but only use node.js, so the command doesn't work. – Z. Clément Sep 06 '15 at 10:01
  • @Logoosse I'm not actually sure how to pass Node options via Meteor, but at least on my server (not locally) I use Node directly (the app's been demetorized) so in that case I can pass whichever options I want. – aknuds1 Sep 06 '15 at 10:02
  • I've asked on the Meteor forum now though, how you can pass this option via Meteor. – aknuds1 Sep 06 '15 at 10:11
1

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).

Community
  • 1
  • 1
Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
1

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.

alonso_50
  • 1,442
  • 13
  • 16