我正在尝试为在Tomcat服务器下运行的我的一个应用程序使用JProfiler。

因此,我编写了一个内存泄漏servlet,如下所示。

@SuppressWarnings(value = { "" })
public class Dust extends HttpServlet {
protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    String str = new String();
    List myarrylist = new ArrayList();
    int i = 10;
        while (true) {
    myarrylist.add(str);
    System.out.println(i);
        i++;
    }
}
}


现在,当我使用本地运行的Profile Web Application在此Application上运行JProfiler时。
它给了我这种看法。请看这里的屏幕截图

http://tinypic.com/view.php?pic=2r5c2nq&s=7

我有这些问题:


它表明正在创建许多String对象。
(但是,由于在一个应用程序中可能有很多字符串,所以我们怎么知道在哪个类/ servlet中以及确切地由哪个字符串真正负责此对象的创建。)
以及为什么启动按钮(我高亮显示)被禁用了?
通过单击“开始”按钮启动JProfiler就足够了(请参见该图片),并且我们也不需要启动Tomcat服务器吗?


请帮忙 。谢谢 。

最佳答案

您必须为此使用堆遍历器。动态内存视图无法显示有关引用的任何信息,因为必须创建快照。

请参阅this screen cast以获取有关如何使用JProfiler查找内存泄漏的更多信息。

09-09 23:40
查看更多