aspose file tools*
The moose likes JDBC and the fly likes web application memory leak Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "web application memory leak" Watch "web application memory leak" New topic
Author

web application memory leak

Islam Kamrul
Greenhorn

Joined: Feb 14, 2003
Posts: 2
I am getting a memory leak with a web application I am developing and would appreciate help in tracking down the cause.
General Application Structure:
* The application follows a standard Model-View-Controller (MVC) Pattern. All requests are handled by a Controller servlet which queries the database (via a helper class which is instantiated in the Controllers Init() method) and then passes to JSP view.
* The helper class opens a connection pool to a Lotus Notes database (type II driver), executes the query and passs back the results in a Arraylist and a Hashmap.
Test Environment:
Tomcat 4.0.3 on Windows 2000, JDK is 1.3.1
When stress testing the application the memory usage goes up after each test and the memory resources do not get released, until eventually it crashes the tomcat server.
Here's the helper class method that is used by the servlet to get an Arraylist of products to display. myConn is the Connection Pool
public ArrayList getStockItems(String[] ref)
throws SQLException, ClassNotFoundException {
tempConn = myConn.getConnection();
ArrayList products = new ArrayList();
try {
products.clear();
for (int i = 0; i < ref.length; i++) {
stmt = tempConn.createStatement();
rs = stmt.executeQuery("SELECT * FROM IsStockView
WHERE prodCode ='"+ref[i]+"'");

while (rs.next()) {
prodCode = rs.getString("prodCode");
prodName = rs.getString("prodName");
// various other details retrieved...
tempStockItem = new StockItem(prodCode, prodName,...);
products.add(tempStockItem);
}
rs.close();
}//end of for loop..
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (tempConn != null) {
myConn.releaseConnection(tempConn);
}
}
return products;
}
I have run this also with JProbe memory debugger, but finding it difficult to interpret the results - there doesn't seem to be any obvious loitering objects. I am wondering if the leak could be with the JDBC driver. How can I confirm if the driver is the problem, given it is Type II and uses the Notes C++ API?
All views and opinions will be appreciated.
--
Thanks
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
I can't guarantee this is it, but I've personally had a number of problems with large collection objects that don't have all their child objects cleaned up. The issue is weak references. As long as something holds a reference to a object entire graphs of objects can be prevented from being correctly garbage collecte. I ussually solve this by creating recursive destructors which I explicity call to null out the object references to avoid memory issues. I would suggest using your profile tool again to look specifically at these collections to see if that's the offending object.
Good luck!


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
 
Don't get me started about those stupid light bulbs.
 
subject: web application memory leak
 
Similar Threads
Problems when viewing specific description when search
Deploying Hibernate 3 application in Jboss 4.0.2
web application memeory leak
How to use Usebean Tag and setProperty and getProperty
Unable to find specific product