This patch adds a --heapsnapshot-near-heap-limit CLI option that takes heap snapshots when the V8 heap is approaching the heap size limit. It will try to write the snapshots to disk before the program crashes due to OOM. PR-URL: https://github.com/nodejs/node/pull/33010 Refs: https://github.com/nodejs/node/issues/27552 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
14 lines
386 B
JavaScript
14 lines
386 B
JavaScript
'use strict';
|
|
|
|
const { Worker } = require('worker_threads');
|
|
const path = require('path');
|
|
const max_snapshots = parseInt(process.env.TEST_SNAPSHOTS) || 1;
|
|
new Worker(path.join(__dirname, 'grow.js'), {
|
|
execArgv: [
|
|
`--heapsnapshot-near-heap-limit=${max_snapshots}`,
|
|
],
|
|
resourceLimits: {
|
|
maxOldGenerationSizeMb:
|
|
parseInt(process.env.TEST_OLD_SPACE_SIZE) || 20
|
|
}
|
|
});
|