0

我正在尝试在我的 Android 应用程序中查找内存泄漏。我有以下情况:

A 类创建了一个 A$24 类,它创建了一个线程。这个线程有一个类 A 的引用,所以这就是泄漏。我知道 A$24 是在 A 类中创建的匿名类,但我怎样才能找出在哪里创建,在代码中的哪一行。我的问题是了解谁是有问题的线程。

4

1 回答 1

1

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).

于 2012-07-17T20:41:44.770 回答