Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory leak in vm ? JDK1.6_0.6

0 views
Skip to first unread message

Stefan

unread,
Oct 29, 2008, 6:04:46 AM10/29/08
to
I wrote the reference implementation of the
com.sun.net.httpserver.HttpServer
It seems to be a memory leak in JVM or do i leave some resources
open.

Thankful if you have some suggestions!

mport java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;

class Server implements HttpHandler
{
public void handle( HttpExchange httpExchange ) throws IOException
{
httpExchange.getResponseHeaders().add( "Content-type", "text/
html" );
String response = "test ";
httpExchange.sendResponseHeaders( 200, response.length() );

OutputStream os = httpExchange.getResponseBody();
os.write( response.getBytes() );
os.close(); //
}
public static void main(String[] args) {
HttpServer server = null;
try {
server = HttpServer.create( new InetSocketAddress( 80 ), 0 );
} catch(IOException e) {

}
server.createContext( "/", new Server() );
server.start();

}
}

sinka...@gmail.com

unread,
Oct 31, 2008, 12:59:04 PM10/31/08
to
Never had a chance to llook at Sun's HttpServer but your source seem
to fine from leak point of view. JDK1.6.x has some leak issues when
there is a ClassCastException (the one what i experienced), you may
attach a debuger to pick ClassCastException to see if there is any.

This may not happen in your code but may happen somewhere in the
underlying API's and those are never reported and digested internally.

I had applied a fix for the same to get things going smoothly on one
of our demo earlier, here's the detail
http://mad-magnum.blogspot.com/2008/09/jdk16-hotspot-vm-leak-out-of-swap-space.html

0 new messages