views:

151

answers:

2

I have an app with about 15 threads. Most do mundane tasks and sleep most of their lives. Others collect information and cache it in hashmaps. The hashmaps grow to a moderate size and level out. The number of keys and size of value remains constant, but the contents of the values changes (at 33 keys per second average).

When I start my app, I notice the garbage collection interval goes from minutes to once per second, and the amount of garbage is 700k+ each time.

In fact as I was writing this, it caused my phone to reboot with an error "Referencetable Overflow".

Here's my question: Are there any tricks to identifying which threads are producing the garbage, or even finding out more about what garbage they are producing?

05-26 22:08:57.052 W/dalvikvm( 1031): ReferenceTable overflow (max=512)
05-26 22:08:57.052 W/dalvikvm( 1031): Last 10 entries in JNI local reference table:
05-26 22:08:57.052 W/dalvikvm( 1031):   502: 0x449904a8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   503: 0x4494fda8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   504: 0x44a172c8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   505: 0x448c7900 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   506: 0x44842b18 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   507: 0x448e9eb8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   508: 0x449c6ae0 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   509: 0x44998138 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   510: 0x44961ae0 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031):   511: 0x448ee470 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.060 W/dalvikvm( 1031): JNI local reference table summary (512 entries):
05-26 22:08:57.060 W/dalvikvm( 1031):   487 of Ljava/lang/String; 28B (487 unique)
05-26 22:08:57.060 W/dalvikvm( 1031):    25 of Ljava/lang/String; 36B (25 unique)
05-26 22:08:57.060 W/dalvikvm( 1031): Memory held directly by native code is 14536 bytes
05-26 22:08:57.068 E/dalvikvm( 1031): Failed adding to JNI local ref table (has 512 entries)
05-26 22:08:57.068 I/dalvikvm( 1031): "BT EventLoop" prio=5 tid=81 RUNNABLE
05-26 22:08:57.068 I/dalvikvm( 1031):   | group="main" sCount=0 dsCount=0 s=N obj=0x447cd620 self=0x4d7b38
05-26 22:08:57.068 I/dalvikvm( 1031):   | sysTid=1138 nice=0 sched=0/0 cgrp=default handle=4210840
05-26 22:08:57.068 I/dalvikvm( 1031):   at dalvik.system.NativeStart.run(Native Method)
05-26 22:08:57.068 I/dalvikvm( 1031): 
05-26 22:08:57.068 E/dalvikvm( 1031): VM aborting
05-26 22:08:57.185 I/DEBUG   (  990): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
+1  A: 

There is Allocation Tracker.

Another thing to consider, have you tried using WeakReferences in your hashmaps ?

JRL
@JRL +1 for the allocationTracker. I'm still trying to wrap my head around weakReferences but am failing. I will try using the Allocation Tracker and leave this question unanswered for a bit longer to see what other perspectives come to light.
Brad Hein
The allocation tracker article was great. That is what I needed to shed light on the issue. Thank you.
Brad Hein
A: 

I have same questions. Anyone can help?

mlianghua
To ask a question, ask a new question, don't add your question as an answer to someone else's question.
Brad Hein