joseph
joseph

Reputation: 2816

How to approximate the the 'owner' of lower level objects for a memory leak

My heap histogram tells me I'm using lots of char arrays ([C), byte arrays ([B), hash nodes, and locks.

What tool will tell me who 'owns' these character arrays, byte arrays, hash nodes and locks? I'm expecting that 'ownership' is very ambiguous so what are some methods and tools used to approximate it?

So far I've been following reverse pointers in visualvm starting from the char array, but this only gives me a qualitative feel for the problem. I want numbers.

One idea I had was to follow N (some constant) pointers backwards and group by the paths, summing over #instances and bytes. For example, if I were to jump two pointers backwards from the the character array, I might find the glutton leak:

MB        path
1000      char[] <- String <- LeakingBusinessObject
1         char[] <- String <- OkayBusinessObject

Upvotes: 2

Views: 111

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48015

The heap walker in JProfiler has a view that shows cumulated incoming references. Below you see chains of incoming references for all int[] arrays on the heap:

enter image description here

Disclaimer: My company develops JProfiler

Upvotes: 1

Related Questions