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