Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Java7 Socket Closed Exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java7 Socket Closed Exception

I still would start by logging somewhere each time you say "new Socket()" and each time you say "socket.close()", to make sure those two numbers match...
HItting a limit around 240 suggests you're running into some per-process limit: when I do "ulimit -n" on a terminal on MacOSX, it tells me I can only open 256 files at once.  You could try doing a "ulimit -n 1024" on the shell that will start up your Java program (or the shell that starts up the browser that starts up...).

I think System.gc() is not guaranteed to actually trigger a garbage-collect cycle - but you could start a Java RMI server object within your application, just to get the RMI runtime initialized: it will force a garbage collect once a minute, once Java has published an RMI server object.  This would allow you to see if your problem has to do with uncollected sockets...  Or, from this page: - you might be able to do this:
  1. Open jconsole.exe
  2. Connect to the desired local Process.
  3. Go To memory tab and click perform GC.


On Jun 4, 2013, at 11:31 AM, Ben Spink <email@hidden> wrote:

To get the obvious questions out of the way first...
Are you closing your sockets when you're done with them?  Waiting/Hoping for garbage collection to reclaim your sockets for you is a bad idea...  (Symptoms would look just like what you're experiencing...).


An lsof indicated this might be the issue...

I have about 240+ of these lines:

java      7526       ff7admin 4809u     IPv6 0xbd2d651aa23b725d        0t0    TCP *:* (CLOSED)

Doesn't this indicate the socket is closed?  Does this mean there is a reference being held in memory for that closed socket so its not getting garbage collected?


Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 >Re: Java7 Socket Closed Exception (From: Ben Spink <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.