process memory is larger than 1G, cpu is 100% immediately
sahalazj-github opened this issue · 3 comments
sahalazj-github commented
process memory is larger than 1G, cpu is 100% immediately
sahalazj-github commented
const v8Profiler = require('v8-profiler-next')
const generateVmHeapsnapshot = (options, callback) => {
try {
const { cupFilePath } = options
console.log('EnterGenerateSnapshot', cupFilePath)
const snapshot = v8Profiler.takeSnapshot()
console.log('AfterGenerateSnapshot')
// 1. not as stream
const file = fs.createWriteStream(cupFilePath);
const transform = snapshot.export();
transform.pipe(file);
transform.on('finish', snapshot.delete.bind(snapshot));
} catch(e) {
console.log('GenerateVmHeapsnapshotError', e)
}
}
hyj1991 commented
这是正常的,堆快照序列化是一个比较大的开销,等堆快照生成 cpu 会降下来。
hyj1991 commented
相比之下,进程堆内存比较大时,生成的堆快照的体积一般也比较大,且会耗费一定的时间,这个是没问题的。