osx - Java memory leak when running on Red Hat but no memory leak on Mac OS X -


i have java webobjects app showing memory leak problems when running on red hat had no such problems when running on mac os x. jvms similar.

mac os x 10.6.5 using java 1.6.0_22 64 bit apple red hat el 5.0 using java 1.6.0_20 64 bit sun

i configured heap dump when ran out of memory, , analysing eclipse memory analyzer tool suggests problem in part of code creates thread sends http request web service. reason creating thread implement timeout on request because web service not available.

does have ideas?

    wohttpconnection connection = new wohttpconnection(host, port);     worequest request = new worequest(strmethod, strquery, strhttpversion, nsdheader, content, null);      webservicerequester therequester = new webservicerequester(connection, request);     thread requestthread = new thread(therequester);     requestthread.start();     try {             requestthread.join(inttimeoutsend);  //timeout in milliseconds = 10000             if ( requestthread.isalive() ) {                 requestthread.interrupt();             }     } catch(interruptedexception e) {       }     requestthread = null;     if(!therequester.gettfsent()) {            return null;     }     woresponse response = connection.readresponse(); 

...

class webservicerequester implements runnable {      private worequest therequest;     private wohttpconnection theconnection;     private boolean tfsent = false;      public webservicerequester(wohttpconnection c, worequest r) {         theconnection = c;         therequest = r;     }      public void run() {         tfsent = theconnection.sendrequest(therequest);     }      public boolean gettfsent() {         return tfsent;     } } 

edit: leaked class names reported eclipse memory analyzer tool:

1,296 instances of "java.lang.thread", loaded "<system class loader>" occupy 111,947,632 (43.21%) bytes. 1,292 instances of "er.extensions.eof.erxec", loaded "java.net.urlclassloader @ 0x2aaab375b7c0" occupy 37,478,352 (14.46%) bytes. 1,280 instances of "er.extensions.appserver.erxrequest", loaded "java.net.urlclassloader @ 0x2aaab375b7c0" occupy 27,297,992 (10.54%) bytes. 

i have heard wohttpconnection broken , shouldn't used. wohttpconnection not give reliable way of closing connection. unreliable in other ways.

the solution rewrite code using apache httpcomponents httpclient


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -