Login with  Log in with facebook
Hiring Manager? SIGN UP HERE
3

In what situations Memory Leak can occur in Java. What are the best practices to avoid Memory Leak?

Rishi Yadav
08/06/2011 at 19:09
1 Answer
1
2

    Assume that you choose to solve the problem by tracing the root cause of the problem (the memory leaks), how would you collect data to zoom in on the problem?

Take a heap dump using jmap and load the dump using Eclipse Memory Analyzer. From there you can analyze which objects are eating up the most memory, which "roots" are preventing other objects from being collected, etc.

There are other heap analysis programs, such as jhat, but I've found EMA to be the fastest and best (free) solution.

    Assume that you choose the quick and dirty way of speeding things up by simply restarting the container, how would you collect data to choose the optimal restart cycle?

Use JMX to monitor heap size and other heap and GC statistics.

Maneshwar Meel
09/14/2011 at 22:02

If you want to post any answer to this forum then you need to log in.
Schedule a Demo

Schedule a Demo with us

Name *
Email *
Phone *
Company *
Details