简体   繁体   English

如何获取JSON/XML格式的Eclipse MAT memory泄漏疑似报告?

[英]How to get Eclipse MAT memory leak suspect report in JSON/XML format?

I am trying to add Java memory profiling into my devops pipeline.我正在尝试将 Java memory 分析添加到我的 devops 管道中。 I am using Eclipse MAT command line script for this purpose.为此,我正在使用 Eclipse MAT 命令行脚本。 Once I provide the hprof file as input to this and it generates suspect report.一旦我提供 hprof 文件作为输入,它就会生成可疑报告。 I need to parse this HTML report and make decision based on this.我需要解析这份 HTML 报告并据此做出决定。 This is cumbersome and also the parsing is not structured.这很麻烦,而且解析也不是结构化的。 I want either XML/JSON report or I want to see how the actual report is generated by Eclipse MAT.我想要 XML/JSON 报告,或者我想看看 Eclipse MAT 是如何生成实际报告的。 If I found that I can get the code and customize based on my need.如果我发现我可以获得代码并根据我的需要进行自定义。 Any suggestions on this.对此有任何建议。

Eclipse Memory Analyzer is open source, and all the code is here: https://git.eclipse.org/c/mat/org.eclipse.mat.git Eclipse Memory Analyzer是开源的,所有代码在这里: https://git.eclipse.org/c/mat/org.eclipse.mat.git

The leak suspects code is in https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/FindLeaksQuery.java and https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/LeakHunterQuery.java泄漏嫌疑代码在https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections/ FindLeaksQuery.javahttps://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.api/src/org/eclipse/mat/inspections.LeakHunters/LeakHunter java

The leak suspects report is clean HTML which passes HTML validation, which would aid parsing.泄漏嫌疑人报告是干净的 HTML,它通过了 HTML 验证,这将有助于解析。

Your request for a XML/JSON report is a reasonable one, but is not currently provided by MAT.您对 XML/JSON 报告的请求是合理的,但 MAT 目前不提供。 There is provision for one to be added, using the rendering extension point http://help.eclipse.org/latest/topic/org.eclipse.mat.ui.help/doc/org_eclipse_mat_report_renderer.html .使用渲染扩展点http://help.eclipse.org/latest/topic/org.eclipse.mat.ui.help/doc/org_eclipse_mat_report_renderer.html可以添加一个。 There are already HTML, CSV and TXT renderers and so a JSON extension point could be added.已经有 HTML、CSV 和 TXT 渲染器,因此可以添加 JSON 扩展点。 There are then design decisions to be made about how to represent trees and tables in JSON, and how to convert HTML from say the yellow boxes of the leak suspects report to JSON.然后需要做出关于如何在 JSON 中表示树和表格,以及如何将 HTML 从泄漏嫌疑人报告的黄色框转换为 JSON 的设计决策。

As I know of other people who want a JSON formatted report it may be worthwhile following it up more formally with the MAT community, either on the forum https://www.eclipse.org/forums/index.php?t=thread&frm_id=186 or on Bugzilla or on the developer mailing list if you are proposing to help write code.据我所知,其他人想要一份 JSON 格式的报告,可能值得在 MAT 社区更正式地跟进,或者在论坛https://www.eclipse.org/forums/index.php?t=thread&frm_id= 186或 Bugzilla 或开发人员邮件列表,如果您打算帮助编写代码。

Another option is to implement your own extension: https://wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer#Calling_One_Query_from_Another and call the leak_hunter query.另一种选择是实现您自己的扩展: https://wiki.eclipse.org/MemoryAnalyzer/Extending_Memory_Analyzer#Calling_One_Query_from_Another并调用leak_hunter查询。 Then read through the details of the IResult and transform those to a json object.然后通读IResult的详细信息并将其转换为 json object。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM