If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Memory leak with DB2 9.7 jdbc driver

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-11, 11:54
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
Lightbulb Memory leak with DB2 9.7 jdbc driver

Hello,

We want to upgrade to DB2 9.7.
But we keep getting memory leaks in java.

We have tried the jdbc3 and jdbc4 drivers (latest _3a version march 2011) but both have the same problem.
If we run the code underneath, memory usage keeps on going up until we get an outofmemory error

Code:
      Connection dbConnection = DriverManager.getConnection("jdbc:db2://server:50000/database", "username", "password");
      
      dbConnection.setAutoCommit(false);
      
      PreparedStatement insertStatement = dbConnection.prepareStatement("INSERT INTO table (ID, TIMESTAMP_RECEIVED) VALUES(?, ?)");
      
      int i = 0;
      while (true) {
        
        insertStatement.setString(1,""+i++);
        insertStatement.setTimestamp(2,new Timestamp(System.currentTimeMillis()));
        
        insertStatement.execute();
        insertStatement.clearParameters();
        insertStatement.clearWarnings();
       
        dbConnection.commit();
        if (i % 10000 ==0){
          System.out.println("inserts = " + i);
        }
      }
Did someone also have these problems, or does someone know what's going wrong?

Thanks in advance, Tinie
Reply With Quote
  #2 (permalink)  
Old 03-15-11, 15:00
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Which fixpack are you using for the server and the client driver? Have you tried FP 3a?
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 03-15-11, 15:21
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,195
What is the meaning of "true" in "while (true)"?
Didn't the while loop get into infinite loop?
Reply With Quote
  #4 (permalink)  
Old 03-16-11, 03:58
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
Quote:
Originally Posted by Marcus_A View Post
Which fixpack are you using for the server and the client driver? Have you tried FP 3a?
Whe are using the latest driver.
Is there a difference between a server or client driver?
Reply With Quote
  #5 (permalink)  
Old 03-16-11, 04:00
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
Quote:
Originally Posted by tonkuma View Post
What is the meaning of "true" in "while (true)"?
Didn't the while loop get into infinite loop?
It is our purpose to have an infinite loop, so we can test the memory leak problem.
This app is just a test for the memory leak error.
Reply With Quote
  #6 (permalink)  
Old 03-16-11, 04:15
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Are you sure this is a memory leak? Did you try this piece of code on other databases without trouble?
My java knowledge is limited but is seems to me that you are creating new java-objects and as far as the garbage-collector is conserned they are all used so cannot be touched. This goes as far as your jvm-heap, but a memory leak????
Reply With Quote
  #7 (permalink)  
Old 03-16-11, 04:41
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
Quote:
Originally Posted by dr_te_z View Post
Are you sure this is a memory leak? Did you try this piece of code on other databases without trouble?
My java knowledge is limited but is seems to me that you are creating new java-objects and as far as the garbage-collector is conserned they are all used so cannot be touched. This goes as far as your jvm-heap, but a memory leak????
I have run the test app against an oracle database with the ojdbc14 jdbc driver.
Here everything works fine.
After the memory usage has climbed up to 5mb it falls down to 1mb. And this repeats over and over again.
While with the db2 driver the memory usage only climbs up.
Reply With Quote
  #8 (permalink)  
Old 03-16-11, 05:03
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Is ID a numeric column?
Reply With Quote
  #9 (permalink)  
Old 03-16-11, 05:11
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
Quote:
Originally Posted by shammat View Post
Is ID a numeric column?
No, ID is a VARCHAR
Reply With Quote
  #10 (permalink)  
Old 03-16-11, 10:35
tsluijter tsluijter is offline
Registered User
 
Join Date: Nov 2010
Location: The Netherlands
Posts: 12
It seems we have found the problem.
It wasn't the db2 jdbc driver, but the hardware.

We are doing the same test, with the same harddrive, on other machines and
the memory leak doesn't appear anymore.
Reply With Quote
Reply

Tags
9.7, db2, jdbc, leak, memory

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On