|
Replies:
1
-
Pages:
1
-
Last Post:
Oct 23, 2009 8:07 AM
by: SHodgins
|
|
|
Posts:
2
Registered:
10/19/09
|
|
|
|
Heap memory on char[ ] is growing on
Posted:
Oct 22, 2009 6:19 PM
|
|
|
|
|
I'm doing memory analysis for our application. All I'm seeing is char[] and few other objects are keep growing for every test. But not from my application code. Not sure why char[] is adding all the instances and keep growing. Is this something related to memory leak. why char[] is growing?
Please see the attached memory diff file.
Any help would be appreciated.
Thanks very much.
|
|
|
Posts:
171
Registered:
3/21/07
|
|
|
|
Re: Heap memory on char[ ] is growing on
Posted:
Oct 23, 2009 8:07 AM
in response to: srinulanka_562
|
 |
Helpful |
|
|
It looks like the char[]s are probably held by java.lang.Strings which is not surprising, so the immediate question is what's holding the strings?
First, set the "Investigate by" drop-down on the Instances view to "Recorded Count" or "Recorded Memory" so that we only look at instances seen during your collection session (rather than all of the ones in the heap).
Then you can select the char[] entry on the Instances view (or the java.lang.String entry) and right-click to get the context menu, then select "Why is this live?" to see a new view, Dominating Instances, that shows you what instances pinned this set of instances and prevented them from being garbage collected. With char[]s that will likely lead first to java.lang.String -- no surprise. On this new view, you can then select the java.lang.String row, plus any others that look interesting, and right click to again ask "Why Are these Live?". In many cases a few iterations of this will uncover something that is part of your application code that's pinning all of these objects in memory.
Very often while doign this you'll see some sort of collection class -- array, vector, map -- holding a collection of instances, and you can continue past that to see what's holding that. Eventually you will hit <JVM process roots> which represents the top of the reference chain, but hopefully along the way you will see some of your classes and can investigate further from these.
|
|
|
|
Legend
|
|
Guru: 2001
+
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|