possible leaked file descriptors

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

User avatar
aakture
Posts: 23
Joined: 05 Jun 2012, 18:46

possible leaked file descriptors

Postby aakture » 03 Jul 2013, 00:10

Hi, for our test harness, we maintain 1000+ SFS 2X clients in a jvm. We have the clients connect and disconnect periodically. I think due to the way netty manages channels, we will see many open file descriptors (50k+ for 1000 SFS 2X clients), and after open/close cycle, there are a continually increasing number.

I can increase the ulimit on the test host to allocate enough, however, we find that every connect/disconnect cycle will leave 25 or so file descriptors open ( use: ls /proc/`pidof java`/fd | wc -l on linux to get a count ). So after some long running load tests, we will hit a "Too many open files" error in Java, due to running out of file descriptors. I ran some small test code to verify this below ( an you verify this is an issue?).

Would this be something that's fixable in the SFS 2X client, or is it possibly an netty issue?

Thanks.


Code: Select all

public class SFSMain {
   private static Logger         log      = LogManager.getLogger(SFSMain.class);

   public static void main(String[] args) {
      try {
         Thread.sleep(30000);
         SFSClient client = new SFSMain().new SFSClient();
         for (int i = 0; i < 100; i++) {
            client.connect();
            Thread.sleep(1000);
            client.disconnect();
         }
      } catch (InterruptedException e) {
         log.error("error", e);
      }
   }
    class SFSClient implements IEventListener {
      private SmartFox   sfsClient;
      public SFSClient() {
         sfsClient = new SmartFox();
      }
      public void connect() {
         sfsClient.addEventListener(SFSEvent.CONNECTION, this);
         sfsClient.setUseBlueBox(false);
         sfsClient.connect("208.95.105.221", 3399);
      }
      public void disconnect() {
         sfsClient.removeAllEventListeners();
         sfsClient.disconnect();
      }
      @Override
      public void dispatch(BaseEvent arg0) throws SFSException {
         log.info("received event: {}", arg0);
      }
   }
}
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: possible leaked file descriptors

Postby Lapo » 03 Jul 2013, 07:35

Yes, it is a known Netty issue although it shouldn't do any harm when using the API in the regular way.

If you're running hundreds of clients in the same JVM and these clients connect and disconnect frequently the problem will manifest itself at a certain point.
There is possibly a workaround for this issue but it requires lots of testing on our part to make sure it doesn't break anything else, therefore we haven't released an update on that front so far.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
aakture
Posts: 23
Joined: 05 Jun 2012, 18:46

Re: possible leaked file descriptors

Postby aakture » 03 Jul 2013, 18:29

It looks like this is fixed in netty 3.6.6.Final. I tried swapping in 3.5.8, and it was still leaking. But with 3.6.6.Final, I don't see the leak.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: possible leaked file descriptors

Postby Lapo » 03 Jul 2013, 18:40

Oh, that's strange. In the Netty bug database they were saying that they were not going to fix the problem.
So maybe they have changed their mind? Good to know, I will take a look at the release note and see what they did.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
aakture
Posts: 23
Joined: 05 Jun 2012, 18:46

Re: possible leaked file descriptors

Postby aakture » 08 Jul 2013, 20:50

Looks like it maybe was fixed, if this is the same issue: https://github.com/netty/netty/issues/1301

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 15 guests