简体   繁体   中英

Find 2 equals objects in different heap dump using visualvm

I have some memory leak in my java application. I've made 2 heap dumps using jmap. And I see that there is 200 of objects which grow up and I suppouse that it's the reason of memory leak. But I need to verify that it's exactly the same objects. I use both MAT and visualvm for dump analyzing. So, is there any way to verify that 2 objects from different heap dumps are the same object? I mean may be there is some way to get a hashcode of this objects. I've tried to search by object id, but as I understood later it is an adress of object in memory, so it is useless for me.

I know this question is old but I ended up here trying to find the answer via Google. I find the OQL easier to use in VisualVM than in MAT so I end up with the Object I'm looking for in VisualVM and want to see what references it in MAT. So I need to be able to get the object hashcode in VisualVM. When you have the hashcode in MAT you can get directly to the Object you want to see.

在此处输入图片说明

Once you find the Object you want in the Instances view, right click it and do Copy ID . This will get you the hashcode. You can then take this to MAT and find everything that references it, everything it references, etc.

在此处输入图片说明

So, to answer your question, you can compare the hashcode such that if two Object's have the same hashcode they are the same Object. The hashcode is the location in memory where the object was created. It can be moved around by the Garbage Collector, if it is long lived, etc. But for your purposes if two Objects are at the same location now then they are the same Object and have the same hashcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM