Frage

I am trying to find memory leaks in my Android application. I have the following situation:

class A created a class A$24 which created a thread. This thread has a reference to class A, so this is the leak. I understand that A$24 is an anonymous class created in class A, but how can i find out where is was created, in which line in the code. My problem is to understand who is the problematic thread.

War es hilfreich?

Lösung

In the project explorer of the resource perspective use the view menu, select "Customize view..." and uncheck "Inner class files" and "Java output folders". Now you should see the generated class files in the project explorer in a "bin" folder.

If you navigate to your A$24.class file, you can open it using a double click. Look for lines at the top talking about field selectors, like this

 // Field descriptor #10 Z
  private final synthetic boolean val$fStartMinimized

In this example, a final field fStartMinimized is used by the anonymous class (and therefore copied into the anonymous class). Using that field name you should be able to locate the anynomous class in question.

If there is no such field declaration (and also no method name giving you a clue), then you may get more insight with the ByteCode outline plugin (but I've never used that myself).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top