1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Node.js 利用可能なメモリ量

Posted at

--max-old-space-size で設定する

NODE_OPTIONS="--max-old-space-size=999" 

デフォルト値、1400MB らしい
デフォルトで、積んでるメモリの50%までらしい。

--max-old-space-sizeを設定しても、積んでるメモリによって制限されるっぽい。
384MBのコンテナに--max-old-space-size=300を設定したが、231BMしか使えないぽかった。

.ts
const v8 = require('v8');

const heapStatistics = v8.getHeapStatistics();
const totalHeapSizeMB = (heapStatistics.total_available_size / 1024 / 1024).toFixed(2);

console.log(`Total available heap size: ${totalHeapSizeMB} MB`)
1
0
0

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?