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.