我使用worker_threads 创建了一个worker。像这样:
const WorkerThreads = require('worker_threads');
const worker = new WorkerThreads.Worker('./path/to/a.js');
if (countMemory(worker) > 100 * 1024 * 1024) {
worker.terminate();
}
function countMemory(worker) {
// some code I don't know
}
而且我知道./path/to/a.js
Worker 有一点内存泄漏,所以当它泄漏很多时我必须破坏 Worker。如何获取 Worker 使用了多少内存?