6

Our server runs Node.JS on a cloud PaaS (specifically Bluemix). We can configure the amount of allocated memory through the PaaS dashboard, but I noticed that for values above ~1.4GB you also need to execute node with the --max-old-space-size option (explanation here).

This means that whenever I want to change the size of allocated memory, I have to change it in two places in the settings.

What would happen if I call node --max-old-space-size 99999999999 app.js? Will Node.JS try to allocate 99999999999MB, or will it consider the actual memory-limit of the VM\Container in which it runs? Does it affect the behavior of the GC (i.e. if it looks like there is a lot of free space, the GC will run less times)? Is there a --max-old-space-size use-machine-limits option?

Thanks

Oren
  • 2,767
  • 3
  • 25
  • 37
  • This could be useful, If you are hitting such big limits of memory in your app http://stackoverflow.com/questions/16586705/configuring-v8s-memory-management-to-be-smart-for-a-node-js-process – Rabea Apr 07 '16 at 14:56

2 Answers2

5

What would happen if I call node --max-old-space-size 99999999999 app.js? Will Node.JS try to allocate 99999999999MB, or will it consider the actual memory-limit of the VM\Container in which it runs?

Node will not allocate the said memory, but it will attempt to, in response to growing memory demand, if that happens, in the application - incrementally, in reasonably small chunks.

Does it affect the behavior of the GC (i.e. if it looks like there is a lot of free space, the GC will run less times)?

Yes, the tenure space can contain lot of garbage, and the de-allocation will be less frequent.

Is there a --max-old-space-size use-machine-limits option?

Honestly, I don’t know - but will research on this, and update here, if I get information on this.

Hope this helps.

Gireesh Punathil
  • 1,344
  • 8
  • 18
  • According to this: https://github.com/nodejs/node/issues/2738#issuecomment-138621483, there doesn't seem to be a "use-machine-limits" option, you need to explicitly set it. – FrontierPsycho Aug 22 '16 at 07:34
0

giving large heap size will make gc slow and will retain old values. However giving large heap size will cause frequent gc operations and there might be threat of getting “Out-of-Memory” exception

Ashutosh Ranjan
  • 642
  • 5
  • 12