Javascript 在heapdump比较中找不到对象
我安装了Javascript 在heapdump比较中找不到对象,javascript,node.js,v8,heap-dump,Javascript,Node.js,V8,Heap Dump,我安装了heapdumpnodejs模块以转储heap对象 使用本规范(nodejs6.9.1) 为什么? 编辑: 将代码移动到setTimeout中,dump diff将正确显示这两个对象 setTimeout(() => { heapdump.writeSnapshot() const obj = { test: 2, foo: 6.4, wow: true, a: { } } heapdump.writeSnapshot() con
heapdump
nodejs模块以转储heap对象
使用本规范(nodejs6.9.1)
为什么?
编辑:
将代码移动到setTimeout中,dump diff将正确显示这两个对象
setTimeout(() => {
heapdump.writeSnapshot()
const obj = {
test: 2,
foo: 6.4,
wow: true,
a: { }
}
heapdump.writeSnapshot()
console.log(obj)
}, 1000)
注意:test和foo属性不在dump diff中。这段代码说明了我对这个问题的评论
heapdump.writeSnapshot()
const obj = {
test: 2,
foo: 6.4,
wow: true,
a: { }
}
heapdump.writeSnapshot(function(err, filename) { // this is the callback
console.log(obj);
})
您应该使用文档建议的有效回调:。。作者实际上意识到了这种“搭便车”效应
setTimeout(() => {
heapdump.writeSnapshot()
const obj = {
test: 2,
foo: 6.4,
wow: true,
a: { }
}
heapdump.writeSnapshot()
console.log(obj)
}, 1000)
heapdump.writeSnapshot()
const obj = {
test: 2,
foo: 6.4,
wow: true,
a: { }
}
heapdump.writeSnapshot(function(err, filename) { // this is the callback
console.log(obj);
})