Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leak caused by java.lang.ref.FinalizerReference

Tags:

when launch com.android.gallery3d and press back key for about 2000 times i got exception of java.lang.OutOfMemoryError. Dump heap of com.android.gallery3d which is in android 4.0.4.Use MAT to analyse and found java.lang.ref.FinalizerReference was nested called. What could cause this nested called?

android.app.ContextImpl @ 0x418f8c98 android.media.AudioManager @ 0x419495c8 android.media.AudioManager$1 @ 0x41949688 java.lang.ref.FinalizerReference @ 0x419496a8 java.lang.ref.FinalizerReference @ 0x419496e8 java.lang.ref.FinalizerReference @ 0x41949800 java.lang.ref.FinalizerReference @ 0x41949848 java.lang.ref.FinalizerReference @ 0x41949890 java.lang.ref.FinalizerReference @ 0x419498d8 java.lang.ref.FinalizerReference @ 0x41949920 java.lang.ref.FinalizerReference @ 0x419499b0 java.lang.ref.FinalizerReference @ 0x419499f8 java.lang.ref.FinalizerReference @ 0x41949a40 java.lang.ref.FinalizerReference @ 0x41949a88 java.lang.ref.FinalizerReference @ 0x41949ad0 java.lang.ref.FinalizerReference @ 0x4194a5a8 java.lang.ref.FinalizerReference @ 0x4194af48 java.lang.ref.FinalizerReference @ 0x4194b878 
like image 784
user1871434 Avatar asked Dec 03 '12 02:12

user1871434


People also ask

Which of the following can cause memory leak in Java?

Java heap leaks: the classic memory leak, in which Java objects are continuously created without being released. This is usually caused by latent object references.

Can memory leak in Java Yes or no?

Yes. Memory leaks can still occur even when you have a GC. For example, you might hold on to resources such as database result sets which you must close manually.


1 Answers

I had these symptoms in my application and it turned out to be related to a memory leak. I used to register a callback from an activity to a singleton object. Destruction of the activity was pending on that of callback.

like image 158
n0rm1e Avatar answered Nov 08 '22 09:11

n0rm1e