用MAT分析内存——关于UTF字符的问题
我收到一个 .hprof 文件,并使用 Eclipse Memory Analyzer (MAT) 对其进行分析。
我运行“顶级组件”报告,并在“重复字符串”部分中,MAT 检测到一些具有相同内容的字符串实例。
我正在处理 String.intern() 和其他作业,但现在这不是我的问题。 该报告向我显示了如下重复的字符串:
- \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000....
- \u000a\u0009\u0009 \
- u000a\u0009\u0009\u0009\u0009 等等。
其他字符串是可读的,但是这些字符串呢?我认为它们来自 XML 解析(我在我的应用程序中使用 JibX)。
我的问题是:
- 你认为这些字符串会带来什么?我怎样才能更好地分析它们?
- 如果它们来自 XML 解析或其他内容,解析后如何清理/清除它们?也许 JibX 1.0.1 版本对于这些问题来说太旧了?
任何有关这些 UTF-8 之类的 字符串的建议将不胜感激。提前致谢。
I get an .hprof file and I'm analyzing it with Eclipse Memory Analyser (MAT).
I run Top Component report and, in Duplicate Strings section, MAT detects some String instances with identical content.
I'm working with String.intern()
and other homework for me, but now this is not my question.
That report shows me duplicated Strings like these:
- \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000....
- \u000a\u0009\u0009
- \u000a\u0009\u0009\u0009\u0009
And so on.
Other Strings are readable, but, how about these ones? I'm thinking they are from XML parsing (I use JibX in my app).
My questions are:
- What do you think these strings are coming? How can I analyse them better?
- If they are from XML parsing or something else, how can I clean/clear them after parsing? Maybe is JibX 1.0.1 Release too old for these issues?
Any suggestion about these UTF-8 like Strings would be very appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以右键单击可疑字符串并选择“列出对象/包含传入引用”。这将向您显示引用字符串的对象。
You can right-click on the suspicious String and select List Objects/With Incoming References. This will show you the objects that reference your Strings.
有趣的是看到带有许多 \u0000 个字符的字符串,考虑到字符串在 Java 中不是以 0 结尾的事实,这是非常不常见的,因此它们是从 String(byte[]) 构造函数创建的,也许是 String(byte[] ,encoding) 构造函数,来自包含 0 的字节数组。
我将使用探查器并分析这些构造函数的调用图。然后你就会找到罪魁祸首。
It is interesting to see Strings with many \u0000 characters, which is very uncommon given the fact that Strings are not 0-terminated in Java, so they are created from a String(byte[]) constructor, maybe a String(byte[],encoding) constructor, from byte arrays containing 0s.
I would use a profiler and analyse the call graphs of these constructors. Then you will find the culprit.