LoginSignup
15

More than 3 years have passed since last update.

node.js の --max-old-space-size のデフォルト値は 1400MB

Last updated at Posted at 2020-02-05

node.js の V8 のヒープのメモリ容量を設定するオプション --max-old-space-size のデフォルト値は 1.4GB みたい。

    max_old_generation_size_ = 700ul * (kSystemPointerSize / 4) * MB;

64bit OS だと kSystemPointerSize は 8 だろうから、1400MB になりそう。
実際の値をみると、--max-old-space-size=1400 の結果とマッチした。

node --max-old-space-size=1000 -e 'console.log(Math.floor(v8.getHeapStatistics().heap_size_limit/1024/1024))'
# 1049

node --max-old-space-size=1400 -e 'console.log(Math.floor(v8.getHeapStatistics().heap_size_limit/1024/1024))'
# => 1456

node -e 'console.log(Math.floor(v8.getHeapStatistics().heap_size_limit/1024/1024))'
# => 1456

node --max-old-space-size=2000 -e 'console.log(Math.floor(v8.getHeapStatistics().heap_size_limit/1024/1024))'
# => 2066

node --max-old-space-size=3000 -e 'console.log(Math.floor(v8.getHeapStatistics().heap_size_limit/1024/1024))'
# => 3083

まとめ:
--max-old-space-size=1000 にすると、デフォルトより3割くらい減る。
--max-old-space-size=2000 にすると、デフォルトより4割くらい増える。
--max-old-space-size=3000 にすると、デフォルトより2倍ちょっと増える。

他の記事で --max-old-space-size=2000 をよくみるのは、増やしすぎない按配なのか。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15