From owner-freebsd-java@FreeBSD.ORG Tue Mar 16 18:00:21 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 825F716A4CE for ; Tue, 16 Mar 2004 18:00:21 -0800 (PST) Received: from srv04.bkmedia-hosting.com (srv04.bkmedia-hosting.com [69.57.140.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2865F43D2F for ; Tue, 16 Mar 2004 18:00:21 -0800 (PST) (envelope-from spam@msn2go.com) Received: from rescue (host39.200-117-145.telecom.net.ar [200.117.145.39]) (authenticated (0 bits))i2H1rcD19866 for ; Wed, 17 Mar 2004 02:53:39 +0100 Message-ID: <011a01c40bc3$cd534050$0200a8c0@rescue> From: "Nick Gieczewski" To: Date: Tue, 16 Mar 2004 23:01:41 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Subject: java.net.SocketException: Too many open files X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2004 02:00:21 -0000 Hello folks, My FreeBSD 4.8-STABLE server is running a Java server application that = has recently had an increase in concurrent users. The JDK is = jdk-1.4.2p5. Since the user surge, the main thread has been dying = repeatedly during peak hours at ServerSocket.accept() with the following = message: Exception in thread "main" java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method) Now, here comes the weird stuff: My system is _not_ running out of file = descriptors when this happens (kern.maxfiles =3D 16384, kern.openfiles = =3D ~630), _nor_ is the per-process file descriptor limit being reached = (it's set to unlimited). The heap is not full, either; its maximum size = is set to 128 MB and it's under 60 MB when the thread dies. And there's = plenty of both physical and virtual memory left. I have written a small program that attempts to open 2,048 concurrent = connections to the server in oder to reproduce this. On my FreeBSD box, = the thread dies with the above exception at 500-600 open connections. = When running the server application on Win32, on the other hand, I'm = able to open all the 2,048 connections without a hitch. In a nutshell, I'm getting a "Too many open files" error message but the = message appears to be lying. The system-wide file descriptor limit is = far from being reached, the per-process limit can never be reached, the = heap is far from being full, and there's a reasonable amount of free = physical and virtual memory. And the problem does not occur when the = server application is run on the Win32 version of the JDK. Has anyone run into this problem before, or does anyone know of a fix or = whether it's been fixed in jdk-1.4.2p6? I could just go ahead and = compile p6, but it would take many hours and I can't stress the old = server that much while running this service. Any input will be greatly appreciated. Thanks, Nick