how to get leak info from memlab console
susakin opened this issue · 6 comments
node.js 里用 run
API 和 findLeaks
API,输出结果应该和 CLI 里面用 memlab run ...
和 memlab find-leaks ...
在console里面输出结果是一样的(就像你的第一个截图)。第二张截图好像不是 memlab run
或者 find-leaks
的输出。
所有console输出同时也在 ${workDir}/data/cur/console-log.txt
里面有备份。
In Node.js, using the run
API and findLeaks
API should produce the same console output as using memlab run ...
and memlab find-leaks ...
in the command-line interface (similar to your first screenshot). It seems like the output in the second screenshot isn't from the memlab run
or find-leaks
command.
All console outputs are also backed up in ${workDir}/data/cur/console-log.txt
.
你好 谢谢回复 我没有表达清楚我的意思,第一张是使用memlab cli 跑出直接输出的内容,第二个截图使用program api,一个是用cli命令 一个是直接使用memlab 提供的api 执行的结果,两者输出的关于leak 格式不太一致。
能否share一下得到第二个截图的代码?这个是JSON.stringify
序列化了run
API 的返回值吗?
Can you share your code that got you the second screenshot? Did you pass the return value of the run
API to JSON.stringify
?
CLI 输出的是无结构的string representation方便阅读。findLeaks
API 调用返回的是结构化的memory leak信息便于调用程序进行后续处理。如果需要得到CLI的string输出结果可以从${workDir}/data/cur/console-log.txt
读取。
const fs = require('fs');
const path = require('path');
const workDir = createMyWorkDir();
const runResult = await takeSnapshots({scenario, workDir})
const leaks = await findLeaks(runResult);
const cliOutput = fs.readFileSync(path.resolve(workDir, 'data', 'cur', 'console-log.txt'), 'UTF-8');
The CLI outputs a non-structured string representation for easy reading, while the findLeaks
API returns structured leaks representation that is handy for post-processing. If you need to obtain the string output the CLI, you can read them from ${workDir}/data/cur/console-log.txt
.
谢谢我试试看