Generation count for classes in heap

Hi

I am trying to create a memory profiler, and one feature that I would like it to have is when you request a heap dump, it will be able to give you a generation count for each type of class. By the generation count, I mean the number of different ages of all objects of that class. Do you have any ideas how i would go about calculating this figure?

To keep track of the object allocations, i think i will have to use BCI. Then, for each object allocation, I also want to be able to store the stack trace, so I can present on the front end gui what percentage of objects was created by which method. How would I be able to get the stack trace for each object allocation?

Any help would be much appreciated

Thanks

Billy

[757 byte] By [billynillya] at [2007-10-3 9:37:10]
# 1

You can use BCI to track object allocation. If you look at the HPROF demo they you wil see an example which can record the stack trace too. This of course will be expensive if you do this for every object. Another point about tracking object allocation is that often it is more interesting just to know what is keeping an object alive and to find the place where it is inserted into a collection, or set as the value of a static field, etc. Information on generations and how many GCs an object survives is not available via JVM TI.

alan.batemana at 2007-7-15 4:52:46 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...