Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we document --max_old_space_size or is it deprecated? #7937

Closed
GeorgeBailey opened this issue Aug 1, 2016 · 13 comments
Closed

Can we document --max_old_space_size or is it deprecated? #7937

GeorgeBailey opened this issue Aug 1, 2016 · 13 comments

Comments

@GeorgeBailey
Copy link

I have some Node.JS processes taking more memory than I think they require. I suspect this is due to lazy GC.

In my case, I have several Node.JS processes running, across 3 user accounts. (root and two others)

After searching, it seems that I can limit the amount of 'unused' space that is held in memory by simply using the --max_old_space_size=X option. Where X is the number of megabytes allowed.

However, this does not seem to be documented so I am a little concerned that I should not be using it. Can this be documented, or is it deprecated?

@cjihrig
Copy link
Contributor

cjihrig commented Aug 1, 2016

I believe it is not documented because we have tried to stay away from documenting V8 options.

@GeorgeBailey
Copy link
Author

Oh, I see it now. node --help shows an options called --v8-options. That is where it is documented. One might be able to make that more clear, but I'm not even sure that would help, so I'll just close the issue. Thanks.

@vsemozhetbyt
Copy link
Contributor

@cjihrig Here is a link to the v8-flags repo. Could it be helpfull to duplicate it here?

@cjihrig
Copy link
Contributor

cjihrig commented Aug 1, 2016

That's a lot of documentation that would then fall on our shoulders to keep up to date. The V8 project should manage their own documentation IMO. It also looks like that v8-flags repo hasn't been updated in over 2 years.

@vsemozhetbyt
Copy link
Contributor

@cjihrig Oh, no, I mean to duplicate just the link. But if the list is outdated. then may be this is not a good idea. Sorry.

@cjihrig
Copy link
Contributor

cjihrig commented Aug 1, 2016

Ah, sorry, I misunderstood what you meant by "duplicate it." I wouldn't have a strong opinion on duplicating the link if the v8-flags repo was being kept up to date.

@fractalf
Copy link

fractalf commented Jan 2, 2017

+1 on at least mentioning something about max_old_space_size in the docs. If only to link to somewhere else.

  • Whats the default value when running node? (says 0, but that dont make sense)
  • Where to find an official V8 doc on this option? (is there one?)

I agree that it's not Nodes' job to document V8 options, but still believe this memory option is a special case that deserve mentioning in the docs.

Which would be best to use:

#!/usr/local/bin/node --max_old_space_size=4096
..

or

const v8 = require('v8');
v8.setFlagsFromString('--max_old_space_size=4096');
..

Edit:
After 1 hour of searching I'm still have no idea what's the default node value, and that using this v8 option will (officially) guarantee more memory allocated.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jan 2, 2017

@fractalf A posteriori, Node.js sets memory limit near 1.5 GB by default (at least for x64 OS).

@joyeecheung
Copy link
Member

joyeecheung commented Jan 2, 2017

@fractalf FWIW the definitions of default values are in v8/src/heap/heap.cc:

max_old_generation_size_(700ul * (kPointerSize / 4) * MB),
(max_old_space_size is actually used to configure max_old_generation_size when its value is larger than 0). So on 64-bit machines that(the old generation alone) would be 1400 MB.

@fractalf
Copy link

fractalf commented Jan 2, 2017

@vsemozhetbyt @joyeecheung Thanks!

tartavull added a commit to seung-lab/neuroglancer that referenced this issue Jul 14, 2017
webpack for build-min is called with --max_old_space_size=2048
which seems to make travis work again, but we don't know
exactly what this flag is doing, and what was the default
value that we were using.

nodejs/node#7937

This commit also clean some vestigial code from .travis.yaml that
is not needed now that we test inside the docker container.
tartavull added a commit to seung-lab/neuroglancer that referenced this issue Jul 14, 2017
webpack for build-min is called with --max_old_space_size=2048
which seems to make travis work again, but we don't know
exactly what this flag is doing, and what was the default
value that we were using.

nodejs/node#7937

This commit also clean some vestigial code from .travis.yaml that
is not needed now that we test inside the docker container.
william-silversmith pushed a commit to seung-lab/neuroglancer that referenced this issue Jul 14, 2017
webpack for build-min is called with --max_old_space_size=2048
which seems to make travis work again, but we don't know
exactly what this flag is doing, and what was the default
value that we were using.

nodejs/node#7937

This commit also clean some vestigial code from .travis.yaml that
is not needed now that we test inside the docker container.
@ifredom
Copy link

ifredom commented Aug 2, 2018

"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js"
}

instead of:

"scripts": {
"dev": "node --max-old-space-size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --progress --config build/webpack.dev.conf.js"
},

@ifredom
Copy link

ifredom commented Jan 12, 2019

image
使用这个npm包,可以帮助到你. 在使用vue-cli@3时触发。

@KyleMit
Copy link

KyleMit commented Apr 23, 2021

It is now documented under the Command-Line options in the Docs:

--max-old-space-size=SIZE (in megabytes)

Sets the max memory size of V8's old memory section. As memory consumption approaches the limit, V8 will spend more time on garbage collection in an effort to free unused memory.

On a machine with 2GB of memory, consider setting this to 1536 (1.5GB) to leave some memory for other uses and avoid swapping.

$ node --max-old-space-size=1536 index.js

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

No branches or pull requests

7 participants