Making sure NODE_OPTIONS --max-old-space-size is working

To get heap size in megabytes pls use

const v8 = require('v8')
v8.getHeapStatistics().total_available_size / 1024 / 1024

Example 1

node --max-old-space-size=256

v8.getHeapStatistics().total_available_size / 1024 / 1024

284.47106170654297

Example 2

node --max-old-space-size=512

v8.getHeapStatistics().total_available_size / 1024 / 1024

544.9713745117188

Example 3

export NODE_OPTIONS=--max-old-space-size=1024

node

v8.getHeapStatistics().total_available_size / 1024 / 1024

1065.4709014892578

So, as we can see, both command line arg and env variable NODE_OPTIONS work.