开发者

Analysing a JVisualVM profile - finding the source of large numbers of primitive types?

开发者 https://www.devze.com 2022-12-23 06:37 出处:网络
I am trying to reduce the 开发者_Python百科memory footprint of my application. JVisualVM heap dumps report that the objects taking up the most space are:

I am trying to reduce the 开发者_Python百科memory footprint of my application. JVisualVM heap dumps report that the objects taking up the most space are:

  • char[]
  • byte[]
  • int[]

Which isn't particularly helpful. How can I track these objects back to the parent classes that are holding them?

Thanks


VisualVM does compute retained size. You have to add the column manually, the default view doesn't seem to have it though.


Those primitive arrays are likely to be the internal state of things like String, which keeps its state in a char[]. A good profiler will understand this, and will have the notion of "retained size", which describes the size of objects including the size of their sub-objects. This would indicate that String was taking up the space, not char[].

However, I see no mentioned of "retained size" in VisualVM. It doesn't seem to have the proper profiling capabilities of the commercial alternatives.

To see what I'm talking about, try downloading an evaluation of YourKit, and connect that to your app. It's a lot more complex than VisualVM, but it can give you the retained size of the heap objects, and it's quite illuminating. It will also show you what is referencing each of the objects on the heap, so you can trace leaks.

0

精彩评论

暂无评论...
验证码 换一张
取 消