问题
I am trying to use JProfiler for one of my Application which is running under tomcat server .
So i wrote a memory leak servlet as shown below .
@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++;
}
}
}
Now When i ran JProfiler on this Application using the Profile Web Application running locally . It gave me this view . please see the screen shot here
http://tinypic.com/view.php?pic=2r5c2nq&s=7
I have these questions :
It shows that number of String Objects are being created . (But how can we know in what class / servlet and exactly which string is actually responsible for this creation of objects , as we may have many Strings in a Application. ) ??
And why the Start Button ( which i highlited) is being disabled ??
Is starting JProfiler is sufficient by clicking on the start Button ( Please see that image ) , nd dont we need to start the Tomcat server also ??
Please help . Thank you .
回答1:
You have to use the heap walker for that. The dynamic memory views cannot show any information about references because a snapshot has to be created.
Please see this screen cast for more information on how to find a memory leak with JProfiler.
来源:https://stackoverflow.com/questions/7862991/jprofiler-finding-the-memory-leak-reference-name