Hi All,We have a java application which does deal with lots of insert,update and select statement.We are using bonecp. So we took some sample heap and analyse it with MAT and its pointing to jdbc leaking. Thus we went into the codes and ensure that all resultset,statement and connection are closed accordingly. Below is the sample of the donimator tree which is pointing to lots of java.util.HashMap. What could help to exactly the identify the correct problem?

Class Name                                                                          | Shallow Heap | Retained Heap | Percentage
--------------------------------------------------------------------------------------------------------------------------------
                                                                                    |              |               |           
com.mysql.jdbc.JDBC4Connection @ 0xf016d728                                         |        1,120 |     1,467,296 |      6.22%
|- java.util.HashMap @ 0xf0184890                                                   |           48 |     1,308,152 |      5.54%
|  '- java.util.HashMap$Entry[2048] @ 0xf25685e0                                    |        8,208 |     1,308,104 |      5.54%
|     |- java.util.HashMap$Entry @ 0xf1290570                                       |           32 |         6,624 |      0.03%
|     |- java.util.HashMap$Entry @ 0xf05d1098                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf05f2038                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf05f7ef8                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf0622e40                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf06328d8                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf0646338                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf0893f98                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf10d2d78                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf11d9288                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf1248590                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf1253880                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf1380098                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf1564910                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf17ab140                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf17b9150                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf19624f0                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf1b4ecf0                                       |           32 |         4,968 |      0.02%
|     |- java.util.HashMap$Entry @ 0xf01848c0                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf04607f0                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf0488f28                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf0489bf0                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf05d03a8                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf05d2110                                       |           32 |         3,312 |      0.01%
|     |- java.util.HashMap$Entry @ 0xf05d34a0                                       |           32 |         3,312 |      0.01%
|     '- Total: 25 of 644 entries; 619 more                                         |              |               |           
|- com.mysql.jdbc.MysqlIO @ 0xf0183640                                              |          224 |       129,384 |      0.55%
|- java.util.Properties @ 0xf01a5708                                                |           48 |         8,936 |      0.04%
|- java.util.HashMap @ 0xf01c1a60                                                   |           48 |         3,472 |      0.01%
|- java.lang.String[256] @ 0xf0183230                                               |        1,040 |         1,040 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$StringConnectionProperty @ 0xf017c928    |           64 |           544 |      0.00%
|- java.util.GregorianCalendar @ 0xf01c29b0                                         |          112 |           504 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$StringConnectionProperty @ 0xf016eda0    |           64 |           456 |      0.00%
|- java.util.HashMap @ 0xf017ceb0                                                   |           48 |           448 |      0.00%
|- java.util.GregorianCalendar @ 0xf01c27f0                                         |          112 |           448 |      0.00%
|- java.lang.Throwable @ 0xf01a55e8                                                 |           32 |           288 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016de08|           80 |           176 |      0.00%
|- java.util.HashMap @ 0xf017d070                                                   |           48 |           128 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf017ce48   |           72 |           104 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016e998|           80 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016ed40|           80 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$LongConnectionProperty @ 0xf017bca8      |           72 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e078   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e310   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e3e8   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e8c0   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016ea38   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016ea90   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016eca8   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016f028   |           72 |            88 |      0.00%
'- Total: 25 of 196 entries; 171 more                                               |              |               |           
class java.lang.ref.Finalizer @ 0xf00011b0 System Class                             |           16 |     1,366,128 |      5.79%
com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0                                         |        1,120 |     1,205,632 |      5.11%
com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0                                         |        1,120 |     1,166,112 |      4.94%
com.mysql.jdbc.JDBC4Connection @ 0xf0094478                                         |        1,120 |     1,164,016 |      4.93%
com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0                                         |        1,120 |     1,123,208 |      4.76%
com.mysql.jdbc.JDBC4Connection @ 0xf00bea28                                         |        1,120 |     1,020,328 |      4.32%
com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0                                         |        1,120 |     1,018,376 |      4.32%
com.mysql.jdbc.JDBC4Connection @ 0xf006ee40                                         |        1,120 |     1,008,784 |      4.27%
com.mysql.jdbc.JDBC4Connection @ 0xf04ad490                                         |        1,120 |       986,104 |      4.18%
com.mysql.jdbc.JDBC4Connection @ 0xf0076a90                                         |        1,120 |       975,592 |      4.13%
com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0                                         |        1,120 |       937,088 |      3.97%
com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0                                         |        1,120 |       890,920 |      3.78%
com.mysql.jdbc.JDBC4Connection @ 0xf021c830                                         |        1,120 |       828,392 |      3.51%
com.mysql.jdbc.JDBC4Connection @ 0xf0097818                                         |        1,120 |       826,992 |      3.50%
com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80                                         |        1,120 |       769,928 |      3.26%
com.mysql.jdbc.JDBC4Connection @ 0xf012b158                                         |        1,120 |       750,448 |      3.18%
com.mysql.jdbc.JDBC4Connection @ 0xf04693e0                                         |        1,120 |       735,320 |      3.12%
com.mysql.jdbc.JDBC4Connection @ 0xf1603618                                         |        1,120 |       728,792 |      3.09%
com.mysql.jdbc.JDBC4Connection @ 0xf147f438                                         |        1,120 |       712,168 |      3.02%
com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0                                         |        1,120 |       473,464 |      2.01%
com.mysql.jdbc.JDBC4Connection @ 0xf148fd70                                         |        1,120 |       432,384 |      1.83%
Total: 22 of 6,692 entries; 6,670 more                                              |              |               | 

--------------------------------------------------------------------------------------------------------------------------------

Without code we can only guess - but one interpretation of that listing is that maybe you keep creating instances of JDBC4Connection that are not being garbage collected - ir you are holding on to a reference to all of them somewhere

Dear James, Below is how we setup the pooling first.

try {
   // setup the connection pool
   BoneCPConfig config = new BoneCPConfig();
  config.setJdbcUrl("jdbc:mysql://**.**.**.**:3306/test1");  config.setUsername("******"); 
  config.setPassword("*******");  config.setMinConnectionsPerPartition(5);
  config.setMaxConnectionsPerPartition(40);
  config.setPartitionCount(1);
  connectionPool = new BoneCP(config); // setup the connection pool  
   }
   catch (SQLException e) {
  e.printStackTrace(System.out);
   }

Then for insert and update queries we do this and below we make sure closed the statement. Finally we do close the db connection too.

Statement stmt1 = null;
stmt1 = dbconn.createStatement();
String insertQuery3 =........
count = stmt9.executeUpdate(insertQuery3);
try{
   if ( stmt1!= null ){  stmt1.close();
}
   else{
   System.out.println("No stm1 exist");

}
}catch(SQLException ex){   System.out.println("SQLException has been caught for stmt1");
ex.printStackTrace(System.out);
}

For select we do this  

Statement stmt2 = null;
stmt2 = dbconn.createStatement(); 
String selectQuery2= .........
ResultSet rs2 = stmt2.executeQuery(selectQuery2);

if(rs2.next())
{

}
try{
   if ( rs2!= null ){  rs2.close();
   }   else{
   System.out.println("No rs2 exist");

}

   if ( stmt2!= null ){  stmt2.close();
   }   else{
   System.out.println("No stm2 exist");

}
}catch(SQLException ex){   System.out.println("SQLException has been caught for stmt2");
ex.printStackTrace(System.out);

Below are some sample MAT leak resutls.

Sample 1

21 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 11,793,200 (76.19%) bytes.
Biggest instances:
com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 958,096 (6.19%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 875,568 (5.66%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 816,048 (5.27%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 754,016 (4.87%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 727,024 (4.70%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 663,872 (4.29%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 618,200 (3.99%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 616,608 (3.98%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 612,544 (3.96%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 598,400 (3.87%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 584,992 (3.78%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 561,224 (3.63%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 531,816 (3.44%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 531,416 (3.43%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 522,184 (3.37%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 482,992 (3.12%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 453,256 (2.93%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 424,656 (2.74%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 187,008 (1.21%) bytes.

Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0

file:///C:/Documents%20and%20Settings/ss/Local%20Settings/Temp/report2060944296830228239/pages/18.html# Reference Pattern
Class Name  Shallow Heap    Retained Heap   Percentage
class java.lang.Thread @ 0xf0003840
40  208 0.00%

Sample 2

21 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 13,827,392 (78.27%) bytes.
Biggest instances:
com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 1,093,888 (6.19%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 957,888 (5.42%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 916,672 (5.19%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 878,392 (4.97%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 841,136 (4.76%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 758,336 (4.29%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 747,240 (4.23%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 735,712 (4.16%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 700,912 (3.97%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 681,336 (3.86%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 668,080 (3.78%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 658,816 (3.73%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 638,208 (3.61%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 605,376 (3.43%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 582,104 (3.29%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 558,344 (3.16%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 523,952 (2.97%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 508,232 (2.88%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf1603618 - 276,944 (1.57%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 275,288 (1.56%) bytes.
com.mysql.jdbc.JDBC4Connection @ 0xf148fd70 - 220,536 (1.25%) bytes.

Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0

file:///C:/Documents%20and%20Settings/ss/Local%20Settings/Temp/report8548522855535006676/pages/18.html# Reference Pattern
Class Name  Shallow Heap    Retained Heap   Percentage
class java.lang.Thread @ 0xf0003840
40  208 0.00%

The total memory occupied by those JDBC connection objects looks to be around 12 MiB. You have 40 connections as the max connection count per partition. Which observation leads you to the conclusion that those are not pooled connections but "jdbc leaks"?

My observation is based on the leak report generated by MAT which are both my sample 1 and sample 2 shown in my previous post. But the last snapshot I took it shows nearly 20Mb. Please correct where I might be wrong.

It's just a leak "suspect" report and not a "sure-shot" leak report. What was the time interval between taking the two snapshots? If that time interval was less than the time for which BoneCP waits before closing an idle connection, you are bound to see connection objects hanging around.

The time interval varies between 24 hours to 36 hours. The problem now I notice at least 21 connection are hanging the memory usage is keep increasing that is what worries me according the leak report?

24 hours doing what? Are you doing any sort of stress testing in those 24 hours? Memory is not the problem here but unclosed connections is. The simplest way to check whether the connections are really "leaking" is to stress test the application. If you are not closing connection object, you will eventually run out of them. If you are not running out, you have got a problem with your pool configuration which isn't closing idle connections.

The application is socket app where the socket connection is made and data is capture and later parse and processed accoridngly. Thus the app is running based on wrapper. When you say stress test how to perform in my case ? Should I make lots of socket connection in one minute ? I am using Bone cp and I just saw there is idle close setting which I am not too sure what to set either?

When you say stress test how to perform in my case ? Should I make lots of socket connection in one minute ?

Yes, stress test is basically hitting your app as hard as you can with requests to exercise/know its limits. In you case you can spawn multiple threads from a test computer (or from multiple computers) and send across requests..

I am using Bone cp and I just saw there is idle close setting which I am not too sure what to set either?

It normally depends. In some cases, there is no problem with having 10-20 connections open to ensure that there is no connection creation overhead when a new request comes in. In some cases, open connections for a long time are not feasible and you can live with the overhead of creating new connections when requests come in after a long idle period. For a low profile application, start with something like 30 minutes and tune accordingly as per your application usage patterns.

Should I like create a client which makes multiples connection at one go. The issue is that I can just run one for loop and make the many socket connection but is serial connection? How to make parallel connection from one machine ? I would like to hit it as hard as possible. Do you what is the default setting for idle close setting for bone cp? In a nutshell in my case now what is your suspect is it due to bone cp not closing the connection for too long is it?

Here is my latest capture of leak suspect,histogram and donimator tree. I can see there is increase in the memory and also retained heap? What does retained heap signify?

Leak suspect report

23 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0" occupy 22,837,152 (82.84%) bytes. 

Biggest instances:

•com.mysql.jdbc.JDBC4Connection @ 0xf016d728 - 1,642,744 (5.96%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0 - 1,399,584 (5.08%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0 - 1,350,016 (4.90%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0 - 1,306,480 (4.74%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0094478 - 1,300,352 (4.72%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0 - 1,182,536 (4.29%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00bea28 - 1,172,592 (4.25%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf04ad490 - 1,135,112 (4.12%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf006ee40 - 1,129,672 (4.10%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0076a90 - 1,106,368 (4.01%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0 - 1,090,464 (3.96%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0 - 1,040,176 (3.77%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf021c830 - 1,017,624 (3.69%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf0097818 - 980,432 (3.56%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80 - 906,112 (3.29%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf04693e0 - 886,608 (3.22%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf147f438 - 877,768 (3.18%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf012b158 - 866,760 (3.14%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf1603618 - 849,680 (3.08%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0 - 648,912 (2.35%) bytes. 
•com.mysql.jdbc.JDBC4Connection @ 0xf148fd70 - 561,552 (2.04%) bytes. 


Keywords
com.mysql.jdbc.JDBC4Connection
sun.misc.Launcher$ExtClassLoader @ 0xf000a4f0
 Reference Pattern
Class Name Shallow Heap Retained Heap Percentage 
class java.lang.Thread @ 0xf0003840  

Histogram

C

lass Name                            |   Objects | Shallow Heap | Retained Heap
---------------------------------------------------------------------------------
                                      |           |              |              
com.mysql.jdbc.JDBC4Connection        |        27 |       30,240 | >= 22,956,032
java.util.HashMap                     |    23,445 |    1,125,360 | >= 19,747,032
java.util.HashMap$Entry[]             |    23,467 |    1,991,256 | >= 19,731,936
java.util.HashMap$Entry               |    26,563 |      850,016 | >= 19,561,376
com.mysql.jdbc.StatementImpl          |    11,531 |    1,752,712 | >= 18,702,232
com.mysql.jdbc.JDBC4ResultSet         |    11,531 |    2,029,456 | >= 15,109,824
byte[]                                |    23,429 |    4,888,840 |  >= 4,888,840
java.lang.String                      |    59,906 |    1,916,992 |  >= 4,549,416
com.mysql.jdbc.Field[]                |    11,524 |      276,496 |  >= 3,315,160
java.util.TreeMap                     |    34,586 |    1,660,128 |  >= 3,052,624
com.mysql.jdbc.Field                  |    11,514 |    1,658,016 |  >= 3,038,672
com.mysql.jdbc.MysqlIO                |        23 |        5,152 |  >= 2,994,832
char[]                                |    59,058 |    2,944,624 |  >= 2,944,624
java.lang.Class                       |     2,437 |       23,040 |  >= 2,630,032
com.mysql.jdbc.Buffer                 |        46 |        1,472 |  >= 2,216,336
java.lang.ref.Finalizer               |     3,506 |      140,240 |  >= 1,786,248
java.util.HashSet                     |    11,557 |      184,912 |  >= 1,674,544
java.util.TreeMap$Entry               |    34,737 |    1,389,480 |  >= 1,392,464
com.mysql.jdbc.RowDataStatic          |    11,514 |      368,448 |  >= 1,289,568
java.lang.Object[]                    |    12,913 |      712,112 |  >= 1,241,352
java.net.SocksSocketImpl              |     3,235 |      362,320 |  >= 1,051,648
java.util.ArrayList                   |    11,829 |      283,896 |  >= 1,001,096
Total: 22 of 2,428 entries; 2,406 more|   486,753 |   27,567,184 |              
---------------------------------------------------------------------------------

Dominator tree

Class Name                                                                          | Shallow Heap | Retained Heap | Percentage
--------------------------------------------------------------------------------------------------------------------------------
                                                                                    |              |               |           
class java.lang.ref.Finalizer @ 0xf00011b0 System Class                             |           16 |     1,786,248 |      6.48%
com.mysql.jdbc.JDBC4Connection @ 0xf016d728                                         |        1,120 |     1,642,744 |      5.96%
|- java.util.HashMap @ 0xf0184890                                                   |           48 |     1,483,688 |      5.38%
|- com.mysql.jdbc.MysqlIO @ 0xf0183640                                              |          224 |       129,296 |      0.47%
|- java.util.Properties @ 0xf01a5708                                                |           48 |         8,936 |      0.03%
|- java.util.HashMap @ 0xf01c1a60                                                   |           48 |         3,472 |      0.01%
|- java.lang.String[256] @ 0xf0183230                                               |        1,040 |         1,040 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$StringConnectionProperty @ 0xf017c928    |           64 |           544 |      0.00%
|- java.util.GregorianCalendar @ 0xf01c29b0                                         |          112 |           504 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$StringConnectionProperty @ 0xf016eda0    |           64 |           456 |      0.00%
|- java.util.HashMap @ 0xf017ceb0                                                   |           48 |           448 |      0.00%
|- java.util.GregorianCalendar @ 0xf01c27f0                                         |          112 |           448 |      0.00%
|- java.lang.Throwable @ 0xf01a55e8                                                 |           32 |           288 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016de08|           80 |           176 |      0.00%
|- java.util.HashMap @ 0xf017d070                                                   |           48 |           128 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf017ce48   |           72 |           104 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016e998|           80 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$MemorySizeConnectionProperty @ 0xf016ed40|           80 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$LongConnectionProperty @ 0xf017bca8      |           72 |            96 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e078   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e310   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e3e8   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016e8c0   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016ea38   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016ea90   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016eca8   |           72 |            88 |      0.00%
|- com.mysql.jdbc.ConnectionPropertiesImpl$IntegerConnectionProperty @ 0xf016f028   |           72 |            88 |      0.00%
'- Total: 25 of 196 entries; 171 more                                               |              |               |           
com.mysql.jdbc.JDBC4Connection @ 0xf015fcf0                                         |        1,120 |     1,399,584 |      5.08%
com.mysql.jdbc.JDBC4Connection @ 0xf0201ba0                                         |        1,120 |     1,350,016 |      4.90%
com.mysql.jdbc.JDBC4Connection @ 0xf04ab3f0                                         |        1,120 |     1,306,480 |      4.74%
com.mysql.jdbc.JDBC4Connection @ 0xf0094478                                         |        1,120 |     1,300,352 |      4.72%
com.mysql.jdbc.JDBC4Connection @ 0xf0467bc0                                         |        1,120 |     1,182,536 |      4.29%
com.mysql.jdbc.JDBC4Connection @ 0xf00bea28                                         |        1,120 |     1,172,592 |      4.25%
com.mysql.jdbc.JDBC4Connection @ 0xf04ad490                                         |        1,120 |     1,135,112 |      4.12%
com.mysql.jdbc.JDBC4Connection @ 0xf006ee40                                         |        1,120 |     1,129,672 |      4.10%
com.mysql.jdbc.JDBC4Connection @ 0xf0076a90                                         |        1,120 |     1,106,368 |      4.01%
com.mysql.jdbc.JDBC4Connection @ 0xf00b7bd0                                         |        1,120 |     1,090,464 |      3.96%
com.mysql.jdbc.JDBC4Connection @ 0xf01a27c0                                         |        1,120 |     1,040,176 |      3.77%
com.mysql.jdbc.JDBC4Connection @ 0xf021c830                                         |        1,120 |     1,017,624 |      3.69%
com.mysql.jdbc.JDBC4Connection @ 0xf0097818                                         |        1,120 |       980,432 |      3.56%
com.mysql.jdbc.JDBC4Connection @ 0xf01c2d80                                         |        1,120 |       906,112 |      3.29%
com.mysql.jdbc.JDBC4Connection @ 0xf04693e0                                         |        1,120 |       886,608 |      3.22%
com.mysql.jdbc.JDBC4Connection @ 0xf147f438                                         |        1,120 |       877,768 |      3.18%
com.mysql.jdbc.JDBC4Connection @ 0xf012b158                                         |        1,120 |       866,760 |      3.14%
com.mysql.jdbc.JDBC4Connection @ 0xf1603618                                         |        1,120 |       849,680 |      3.08%
com.mysql.jdbc.JDBC4Connection @ 0xf15ff7d0                                         |        1,120 |       648,912 |      2.35%
com.mysql.jdbc.JDBC4Connection @ 0xf148fd70                                         |        1,120 |       561,552 |      2.04%
Total: 22 of 6,747 entries; 6,725 more                                              |              |               |           
--------------------------------------------------------------------------------------------------------------------------------

Should I like create a client which makes multiples connection at one
go. The issue is that I can just run one for loop and make the many
socket connection but is serial connection? How to make parallel
connection from one machine ? I would like to hit it as hard as
possible.

There are specialized frameworks/toolkits out there to carry out stress testing (JMeter being one of them). Anyways, if you want to go the simplest route, you'll have to create multiple clients which hit the server. This can be done by creating threads (each thread will perform a request, possibly in parallel if you have multiple cores available) or by spawning multiple Java client processes.

Do you what is the default setting for idle close setting for bone cp?

I don't know for sure but this thread implies that it's 60 minutes. To confirm you really are leaking connections, set the max age to 30 mins (look at this post for config settings), stress test your application, take the snapshot, leave it idle for more than 30 mins, then again take the snapshot. If you still see connection objects hanging around, either the connection timeout isn't working or you are not returning connection objects back to the pool.

Below is what I plan to run for the stress test. What is your opinion? I feel is not parallel enough. I am actually running this whole server app on centos machine do you think I should increase the file descriptor before I run this test?

public class stress1 extends Thread {

public static void main(String[] argv) {
    try {
        for (int i = 0; i < 5000; i++) {
        Socket socket = new Socket("localhost", 18000);
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader in = new BufferedReader(new InputStreamReader(
        socket.getInputStream()));

        out.println("data to my server ");
        System.out.println(in.readLine() + i);

        out.close();
        in.close();
        socket.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
   }
  }
}

Thank you for the posts. I went through so lots of other people are confused well I will then set it as config.setIdleMaxAgeInMinutes(30);. I am following based on its docs here http://jolbox.com/bonecp/downloads/site/apidocs/index.html.

Below is what I plan to run for the stress test. What is your opinion? I feel is not parallel enough.

That piece of code isn't parallel; just extending Thread won't make it parallel/multi-threaded. If you want to keep it simple, I would recommend running the same program multiple times (thereby creating multiple processes) to simulate multiple simultaneous clients.

Dear SOS, I am kind of lost here not too sure how to make it run multiple time? Can you give me more hints thank you?

It just means create multiple processes. For e.g. open up three/four consoles/shell and do:

   java -cp . com.yourpkg.YourTestCode

in each of them. Now you have 3 Java instances running the same code and hence simulating simultaneous requests to your app. Unfortunately I can't simplify it more than that.

Dear SOS,Mine are simple programme so normally I just do this javac stress1.java and run it via java stress1. But in this case I will just have or 4 instance but there wont exactly parallel rite? So I leave the for loop in each of them running? So there is not other option to stress it programmatically?

They will execute simulataneously because you are executing 4 of them and they are running independently (assuming you have enough free cores). If you have spare machines, just execute the program from multiple machines to get true parallel execution.

Dear SOS,How about the for loop should I run as it is or just run 1 loop will do? Thank you.

Adjust the loop iteration count based on how many times or how long you want to run the test. And yes, just one loop should be enough.

Dear SOS,As per simple test I created two instance of it with each having one single loop with 500 count each different instance. IT could work but I dont know is this parallel enough? Normally if there is out of memory my server socket should crash rite ? So I have now captured few different heap as below. I have set this extra in my server socket config.setIdleMaxAgeInMinutes(30);. So what conclusion can I make here ? I guess there is no leak right?

Before the stress test.

  9 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf6d63878" occupy 612,288 (34.18%) bytes. 

    Biggest instances:

    •com.mysql.jdbc.JDBC4Connection @ 0xf66735e0 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6698520 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf66dffc0 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf67254d0 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6d3ce38 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6d48168 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6decec8 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6e05a78 - 68,032 (3.80%) bytes. 
    •com.mysql.jdbc.JDBC4Connection @ 0xf6e1e668 - 68,032 (3.80%) bytes. 
    These instances are referenced from one instance of "com.jolbox.bonecp.PoolWatchThread", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf6d63878"

    Keywords
    com.mysql.jdbc.JDBC4Connection
    com.jolbox.bonecp.PoolWatchThread
    sun.misc.Launcher$ExtClassLoader @ 0xf6d63878
     Common Path To the Accumulation Point
    Class Name Ref. Objects Shallow Heap Ref. Shallow Heap Retained Heap 
    java.lang.Thread @ 0xf6659028 BoneCP-pool-watch-thread Thread 9 104 10,080 704 
    <Java Local> com.jolbox.bonecp.PoolWatchThread @ 0xf6658fd0 9 40 10,080 40 
    partition com.jolbox.bonecp.ConnectionPartition @ 0xf6d3cd30 » 5 80 5,600 592 
    pool com.jolbox.bonecp.BoneCP @ 0xf6d3cc98 » 4 128 4,480 304 
    Total: 2 entries
     9 208 10,080 

1,138 instances of "java.lang.Class", loaded by "<system class loader>" occupy 372,672 (20.80%) bytes. 

Biggest instances:

•class com.mysql.jdbc.SingleByteCharsetConverter @ 0xf6d3a968 - 66,056 (3.69%) bytes. 
•class java.lang.System @ 0xf6d35d58 - 60,776 (3.39%) bytes. 
•class com.mysql.jdbc.ConnectionPropertiesImpl @ 0xf6de8200 - 31,768 (1.77%) bytes. 
•class sun.security.jca.Providers @ 0xe3239a70 - 30,856 (1.72%) bytes. 
•class java.nio.charset.Charset @ 0xf6d41238 - 20,968 (1.17%) bytes. 


Keywords
java.lang.Class
 Reference Pattern

Just after the test.

    The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 2,918,328 (41.83%) bytes. 

    Keywords
    java.lang.ref.Finalizer

     Shortest Paths To the Accumulation Point
    Class Name Shallow Heap Retained Heap 
    class java.lang.ref.Finalizer @ 0xe3739130 System Class  

40 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xe3bfab98" occupy 2,721,200 (39.00%) bytes. These instances are referenced from one instance of "java.util.concurrent.ConcurrentHashMap$Segment[]", loaded by "<system class loader>"

Keywords
com.mysql.jdbc.JDBC4Connection
java.util.concurrent.ConcurrentHashMap$Segment[]
sun.misc.Launcher$ExtClassLoader @ 0xe3bfab98

 Common Path To the Accumulation Point
Class Name Ref. Objects Shallow Heap Ref. Shallow Heap Retained Heap 
java.lang.Thread @ 0xe3481d18 BoneCP-release-thread-helper-thread Thread 38 104 42,560 552 
<Java Local> com.jolbox.bonecp.ConnectionReleaseHelperThread @ 0xe351ff88 38 24 42,560 24 
pool com.jolbox.bonecp.BoneCP @ 0xe3c02120 38 128 42,560 304 
finalizableRefs java.util.concurrent.ConcurrentHashMap @ 0xe3c02250 38 48 42,560 4,568 
segments java.util.concurrent.ConcurrentHashMap$Segment[16] @ 0xe3c02280 38 80 42,560 4,520 
[0] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3456e78 » 7 40 7,840 728 
[14] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe35cb910 » 4 40 4,480 408 
[7] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe33d8dd8 » 4 40 4,480 408 
[8] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe33b2d98 » 4 40 4,480 408 
[10] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3372d38 » 3 40 3,360 320 
[6] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3424f88 » 3 40 3,360 320 
[2] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa7e0 » 3 40 3,360 320 
[13] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3670c78 » 2 40 2,240 248 
[12] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa650 » 2 40 2,240 248 
[15] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3c022d0 » 2 40 2,240 248 
[1] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa920 » 1 40 1,120 176 
[3] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe343ce58 » 1 40 1,120 248 
[9] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa720 » 1 40 1,120 192 
[11] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3351110 » 1 40 1,120 168 
Total: 14 entries
 38 560 42,560  
java.lang.Thread @ 0xe3485120 BoneCP-pool-watch-thread Thread 2 104 2,240 704 
<Java Local> com.jolbox.bonecp.PoolWatchThread @ 0xe351dc80 » 2 40 2,240 40 
Total: 2 entries
 40 208 44,800 

In between before the 30 minutes idle ends.

     Description
    The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 2,918,328 (41.83%) bytes. 

    Keywords
    java.lang.ref.Finalizer

     Shortest Paths To the Accumulation Point
    Class Name Shallow Heap Retained Heap 
    class java.lang.ref.Finalizer @ 0xe3739130 System Class

40 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xe3bfab98" occupy 2,721,200 (39.00%) bytes. These instances are referenced from one instance of "java.util.concurrent.ConcurrentHashMap$Segment[]", loaded by "<system class loader>"

Keywords
com.mysql.jdbc.JDBC4Connection
java.util.concurrent.ConcurrentHashMap$Segment[]
sun.misc.Launcher$ExtClassLoader @ 0xe3bfab98

 Common Path To the Accumulation Point
Class Name Ref. Objects Shallow Heap Ref. Shallow Heap Retained Heap 
java.lang.Thread @ 0xe3484080 BoneCP-release-thread-helper-thread Thread 38 104 42,560 552 
<Java Local> com.jolbox.bonecp.ConnectionReleaseHelperThread @ 0xe351ffa0 38 24 42,560 24 
pool com.jolbox.bonecp.BoneCP @ 0xe3c02120 38 128 42,560 304 
finalizableRefs java.util.concurrent.ConcurrentHashMap @ 0xe3c02250 38 48 42,560 4,568 
segments java.util.concurrent.ConcurrentHashMap$Segment[16] @ 0xe3c02280 38 80 42,560 4,520 
[0] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3456e78 » 7 40 7,840 728 
[14] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe35cb910 » 4 40 4,480 408 
[7] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe33d8dd8 » 4 40 4,480 408 
[8] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe33b2d98 » 4 40 4,480 408 
[10] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3372d38 » 3 40 3,360 320 
[6] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3424f88 » 3 40 3,360 320 
[2] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa7e0 » 3 40 3,360 320 
[13] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3670c78 » 2 40 2,240 248 
[12] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa650 » 2 40 2,240 248 
[15] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3c022d0 » 2 40 2,240 248 
[1] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa920 » 1 40 1,120 176 
[3] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe343ce58 » 1 40 1,120 248 
[9] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe36aa720 » 1 40 1,120 192 
[11] java.util.concurrent.ConcurrentHashMap$Segment @ 0xe3351110 » 1 40 1,120 168 
Total: 14 entries
 38 560 42,560  
java.lang.Thread @ 0xe3485120 BoneCP-pool-watch-thread Thread 2 104 2,240 704 
<Java Local> com.jolbox.bonecp.PoolWatchThread @ 0xe351dc80 » 2 40 2,240 40 

After the 30 minutes idle ends.

 The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 3,938,816 (70.05%) bytes. 

Keywords
java.lang.ref.Finalizer

 Shortest Paths To the Accumulation Point

If you don't see Connection objects hanging around after idle time (30 mins), you are good.

Dear SOS, In production I dont see this I keep seeing there is connection objects there could it be due to data keep coming in? Secondly I am going to run now this test with yajsw as in production I use this wrapper software to run it as a daemon. I increase the loop counter to 1000 and ran 4 instance and with 200 connection the speed was pretty good. In my application there is a function where it sends email so it happened that the test message which I was using triggers the emails. But there were few thousand email and it took few hours before all could reach my inboxes? I have actually close my test server. So where was the emails hanging? Below is the function I use for sending the emails. Could I tweak it to make the sending much faster?

void sendClientEmail(String emailMessageString)
     {
      try 
      {
          Properties props = new Properties();      
          props.put("mail.smtp.host", "**********");        
          props.put("mail.smtp.socketFactory.port", "******");      
          //props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");        
          props.put("mail.smtp.auth", "true");      
          props.put("mail.smtp.port", "*****");         
          Session session = Session.getDefaultInstance(props,new javax.mail.Authenticator()
          {             
            protected PasswordAuthentication getPasswordAuthentication() 
            {                   
            return new PasswordAuthentication("*********","*******");               
            }       
          });



            int count=0;
            System.out.println("\n\nClient Email queue took ready :"+emailMessageString);

               try 
               {
                    String[] eMArray = null;
                    eMArray = emailMessageString.split("@EmL@");

                    Message emailMessage = new MimeMessage(session);            
                    emailMessage.setFrom(new InternetAddress("****************"));
                    if(eMArray.length>1)
                    {
                     for(int iEmail=1; iEmail<eMArray.length ; iEmail++)
                     {
                      String cc1 = eMArray[iEmail];
                      emailMessage.addRecipient(Message.RecipientType.TO,new InternetAddress(cc1));
                     }                          
                     emailMessage.setRecipients(Message.RecipientType.BCC,InternetAddress.parse("**************"));

                    }
                    else
                    {
                     emailMessage.setRecipients(Message.RecipientType.TO,InternetAddress.parse("*************"));   
                    }
                    emailMessage.setSubject("Alerts");
                    emailMessage.setText(eMArray[0]);
                    Transport.send(emailMessage);

               }
               catch (Exception e) 
               {
               System.out.println("Transport Problem");
               e.printStackTrace();
               } 
       }
        catch (Exception e) 
       {
        System.out.println("Main email try got problem");
        e.printStackTrace();
       }     

     }

I haven't really worked with JavaMail before but I can provide a few generic comments.

This thread mentions that Transport.send creates a new connection everytime. You should create the session and transport object just once (maybe create a class EmailSender), and use them to send all your messages.

Also I think we are getting offtopic here; if you have more questions which are not related to your connection pooling issue, create a new thread.

Dear SOS, As per your advice for the mail part I have created a new thread. Back to pooling part well I tried with yajsw looks like results pattern is the same now. The finally leak results just point to this. So what is your conclusion then ?

The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 3,106,480 (51.13%) bytes. 

Keywords
java.lang.ref.Finalizer

Just to add on I got this error suddenly when I have 4 instances with loop count as 1000.

java.net.BindException: Address already in use: connect
    at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.<init>(Socket.java:425)
    at java.net.Socket.<init>(Socket.java:208)
    at stress1.main(stress1.java:23)

Process completed.

In addition I am also monitoring when I keep doing new test the memory % and res value show increase in the top too ?

Don't post the leak results, just check the instance count for Connection objects. If after 30 mins of idle time, the leak report doesn't show any Connection objects, we are good. The error you posted is because you are creating too many client connections in a short amount of time. Why can't you just use the same socket connection for sending across multiple requests?

Yes after 30 minutes there is no Connection objects in this scenario because what I did is that I run the 4 instance then I stop.I dont do any more transaction and after 30 minutes I took the heapdump. "I dont pretty much get you here "Why can't you just use the same socket connection for sending across multiple requests?" Just to let you know what I am doing is that the server socket is running on linux box. On windows using jcreator lite I open 4 different instance of my stresstest codes and I quickly start one after another. So is there anything wrong here?

The error message suggests that you are running out of ports on your local Windows box which kind of seems strange given that you are just sending across 4K requests. Anyways, now that you are sure that there are no leaking connections, there isn't a need for this stress test client.

I am a bit curious why the whole pool of connections are used when there are only 4 socket connections made? I want to further expand the stress test on the socket connetion how to verify on this further?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.