Results 1 to 4 of 4
  1. #1
    mbmsit is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default Socket Class Leak

    Hello all,

    After i close an opened socket connection using java.net.Socket class
    in linux OS , there are some resources left residing in memory ,
    shown as 'can't identify protocol ' in the output of lsof command.

    After some time and after connecting and disconnecting many times, this leak causes the system error "Too many open files".

    How can I make sure all resources reserved by the opened sockets are released properly?

    thanks.
    Last edited by mbmsit; 02-15-2010 at 12:31 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Show us some code around where you open and close the Sockets.
    (Please use CODE tags)

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Are using an open source JVM or one from Sun? Ubuntu comes with an open source JVM by default, and I had some problems with it. The Sun JVM works fine.

  4. #4
    mbmsit is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    this is my code
    Java Code:
    try {
    				Socket s=new Socket("192.168.0.253",143);
    				System.out.println("connect...");
    				
    				s.close();
    				try {
    					Thread.sleep(100000);System.out.println("asd");
    				} catch (InterruptedException e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    			} catch (UnknownHostException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    this code executes sleep duration (100) seconds ,
    in this duration , i detect opened connections by :
    "lsof -p 'process number' "
    same error is displayed :
    "can't identify protocol"

    i have installed sun jvm , nothing new.
    where is the problem ???

Similar Threads

  1. swt socket
    By cuiran in forum SWT / JFace
    Replies: 2
    Last Post: 01-22-2010, 01:34 AM
  2. Help I have a memory leak...
    By cdman52 in forum Java Applets
    Replies: 10
    Last Post: 09-28-2009, 10:37 PM
  3. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 07:02 PM
  4. java.util.logging.StreamHandler memory leak?
    By toadaly in forum Advanced Java
    Replies: 1
    Last Post: 02-23-2009, 02:46 PM
  5. Memory Leak using a Swing Application Project
    By iimasd in forum AWT / Swing
    Replies: 0
    Last Post: 11-27-2007, 10:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •