URL class heavy on COU usage
From: jmm-list-gn (jmm-list.AXSPAMGN_at_sohnen-moe.com)
Date: 09/24/04
- Next message: fm: "Re: IllegalArgumentException"
- Previous message: Paul Lutus: "Re: Converting Time as a string to a Long"
- Next in thread: FISH: "Re: URL class heavy on COU usage"
- Reply: FISH: "Re: URL class heavy on COU usage"
- Reply: Boudewijn Dijkstra: "Re: URL class heavy on COU usage"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Sep 2004 23:07:33 -0700
Hello,
Java v1.4.2_05.
I am using the URL and HttpsURLConnection classes in a program. As soon
as the openConnection() method is called, the CPU usage goes to 100%
greatly slowing the functioning of other programs. When the connection
closes, the usage drops back to normal.
Is this expected? A possible problem in the JVM?
Is there an alternate, low CPU usage, way of connecting?
Here is the code that pegs the CPU meter (less the exception code):
URL url;
String url_str = protocol + "://" + hostname
+ "/" + prefix + "/" + service;
// Create new URL and connect
//
// Let Sun's JSSE to deal with SSL
java.security.Security.addProvider(
new com.sun.net.ssl.internal.ssl.Provider());
System.getProperties().put("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
url = new URL(url_str);
HttpsURLConnection connection =
(HttpsURLConnection) url.openConnection();
// Setup HTTP POST parameters
connection.setDoOutput (true);
connection.setDoInput (true);
connection.setUseCaches(true);
// Get POST data from input StringBuffer containing an XML document
//
String queryString = XmlIn.toString();
// POST data
//
System.out.println("...sending request..."); System.out.flush();
OutputStream out = connection.getOutputStream();
out.write(queryString.getBytes());
out.close();
// get data from URL and return the XML doc as a StringBuffer
//
String data = "";
data = readURLConnection(connection);
// Data is saved and the function exits here closing the connection.
-- jmm dash list (at) sohnen-moe (dot) com (Remove .AXSPAMGN for email)
- Next message: fm: "Re: IllegalArgumentException"
- Previous message: Paul Lutus: "Re: Converting Time as a string to a Long"
- Next in thread: FISH: "Re: URL class heavy on COU usage"
- Reply: FISH: "Re: URL class heavy on COU usage"
- Reply: Boudewijn Dijkstra: "Re: URL class heavy on COU usage"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|