This discussion is archived
0 Replies Latest reply: Feb 2, 2013 4:30 AM by 988703 RSS

Java Memory Monitoring in Web Application

988703 Newbie
Currently Being Moderated
Hi All,

Request you to please review the below mentioned suggestion and provide inputs:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Over the years, I have been involved in some projects involving web development in J2ee. JAVA memory usage is an issue that is common amongst all.

Following are some of the questions that come across to a developer regarding the JAVA memory:

Memory Usage Statistics.
Trending of Memory statistics.
Memory Leak.
Performance optimization in case memory leaks occur.


When it comes to answering the above, the most common suggestion is to enable heap dumps and analyze it using a heap analyzer tool. However, there are times and projects where these options are not approved off and developer is always asked to review code again and again. This is again a frustrating option for someone who has just joined a maintenance project and reading through code is not a feasible option. It has happened to me and I did the following to solve some of my problems and eventually all.

Instead of analyzing heap dumps, I decided to do the following:

Add a request filter to my J2EE application.
Add following log statements in the filter:
URL fired.
Runtime.getRuntime().freeMemory()
Runtime.getRuntime().totalMemory()
Runtime.getRuntime().maxMemory()
Gather data from daily app usage and build some trending statistics.


Not only were we able to decide an optimum memory setting for our server, we were able to detect leaks as well. However, i agree detecting leaks wasn't as simple as it's with other tools considering the debugging effort that's involved.It is not a conventional approach but come sin handy when projects don't want to involve costs and maintain equilibrium at production systems as well.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points