I'm analyzing the memory usage of my program, and I realized it was using 50 mb of memory... what could it possibly need all that for? (the program is fairly simple, it's not hello world but it's only 937 non whitespace lines). So I put it into jhat, and I get a lot of information that has no indication of references for all these Integer, Character and Byte arrays.
Here's the image that shows the biggest memory hogs:
When you click on class[I
, there's a lot of stuff that looks like:
Of the almost 5000 instance counts, most of the memory usage is in the largest 22 arrays (I figured that out using excel), of which 15 have size 2677104. And they seem to be arrays of almost entirely zeroes, as seen here:
Reference chains from rootset gives nothing. Clicking on "Objects reachable from here" doesn't give anything useful, I think:
What is using this memory? I am using the following libraries: netty 3.6.5, mbassador 1.1.7, guice 3.0, guava 14.0.1, logback 1.0.11, joda-time 2.1, gson 2.2.3.
Update: I ran the exact same heap dump into Eclipse MAT and got different results...
I wonder if those large arrays were scheduled for GC and MAT is filtering them out? Perhaps I'm analyzing my program too soon... "about 97% of the time: premature optimization is the root of all evil" - Donald Knuth