简体   繁体   中英

Comparing “objects allocated” in a JVisualVM snapshot to number of instances in a Java heap dump

I was using JVisualVM to look at an application, and I saw many objects of SomeDomainClass in the memory profiler and snapshot. A Java heap dump (.hprof file) produced shortly thereafter contained no instances of SomeDomainClass. Because the memory profiler "displays the total number of objects allocated", and the hprof file contains the objects active in the heap, does this suggest that the application is creating many short-lived instances of SomeDomainClass?

Actually, when you start generating the heap, visualVM will call the GC just before start collecting the objects to determine the live objects. then collecting them.

So if your Heap is not showing any instance of SomeDomainClass class, then yes the SomeDomainClass instants are short-live, in other world, these instances didn't have any reference while generating the heap.

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