I am facing a memory leak. So, I captured a heap dump
for my application, and am trying to analyse it using Memory Analyser Tool (MAT). I clicked on Heap Dump Overview option in the menu of hprof file
. Then , clicked on Class Histogram
. It showed me a list of all objects, grouped by class, taking up the maximum meory. One of which is my cutom hashmap. Now, I want to analyse the entries of this hashmap
.
Any idea how I can do so ? If I click on the custom hashmap name, then click on List Objects->with incoming references
, it just shows list of all objects in the hashmap
& the hierarchy by which these objects was created, & not the actual key-value pairs for the hashmap entries.
P.S. My custom Hashmap:
private Hashmap<Integer, TextCache> mCache;
class TextCache{
Bitmap bitmap;
int left;
int right;
int keyCode;
}
To answer my own question, I was trying to view the hprof file from Java/Debug
Perspective. When I switch to Memory Analysis
perspective, I could view the details of all objects, including key-value pairs for hashmap entries, in an Inspector
-> Attributes
window towards the left.
Edit: "key" attribute of the hashmap entries are still not visible. Only attributes of my custom hashmap entry object, which is the "value" part are visible. So, what I did is, for testing purpose, I put the key attribute (which is an integer), in the custom hashmap entry object, to be able to view it from the Inspector
-> Attributes
from the Memory Analysis
perspective.
class TextCache{
Bitmap bitmap;
int left;
int right;
int keyCode;
int key; // this is actually the key used to insert objects of TextCache into the hashmap.
}
If anybody finds out, how to directly view the "key" part from the hprof file, it would be great.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With