Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: java.io.File Date: Fri, 2 Dec 2011 08:17:15 -0800 (PST) Organization: http://groups.google.com Lines: 67 Message-ID: <20850741.465.1322842636010.JavaMail.geo-discussion-forums@prnu18> References: <1754083.312.1322839502470.JavaMail.geo-discussion-forums@prjr26> <5ushd716i6g4qncg620f49ancol20af51f@4ax.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 216.239.45.130 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1322842637 31377 127.0.0.1 (2 Dec 2011 16:17:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 2 Dec 2011 16:17:17 +0000 (UTC) In-Reply-To: <5ushd716i6g4qncg620f49ancol20af51f@4ax.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=216.239.45.130; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10428 Mark wrote: > Lew wrote: >> Mark wrote: >>> Can a java.io.File object use a OS file descriptor? I am trying to >>> find the source of a fd leak in a[n] application. >> >> At some point, depending on the operations performed by the 'File' insta= nce,=20 >> there may be a file descriptor involved, and then the 'File' instance ce= rtainly >> does use it, at least indirectly via JVM system calls that proxy to OS s= ystem >> calls. >> >> From a Java perspective you should look for unclosed I/O streams/channel= s and=20 >> packratted 'File' instances rather than file descriptors. >=20 > I've done a code inspection and the streams are all explicitly closed. > There are a number of File objects used and I notice that File does > not have a close() method so we have to rely on GC. If there were a 'close()' method, as there is with streams, it would have n= othing to do with GC. 'close()' is for resources (such as file handles). = GC is for heap memory. I only suggested checking for packratted 'File' ins= tances as a foolish guess. Now that I think about it, it is highly unlikel= y that unclaimed instances would have anything to do with your issue. >> Of course I'm shooting in the dark since you've said absolutely nothing = about >> your application, much less provided an http://sscce.org/. >=20 > I know. It would be difficult to produce an example since I cannot > reproduce the problem myself - it happens in production only and I > don't have any access there. >=20 > I get the exception: > java.io.IOException: Cannot run program "/path/to/script": > java.io.IOException: error=3D24, Too many open files Do you have any reason to believe it's your program that holds those files? > The script is called via ProcessBuilder object and I don't see any > obvious problems there. Or subtle ones either, I guess. An irreproducible problem involving disparate runtime environments (inside = and outside the JVM), executing black-box code on an undisclosed platform, = yielding an error message possibly originated by an entity outside the JVM = with no data forthcoming - is that the issue with which you request assista= nce? Note: the preceding paragraph implies a path forward, in that a problem st= atement illuminates prospective solutions. In case you missed it, the path= forward is for you to gain visibility into that plethora of unknowns, or s= adly report to your client, as we do to you, that with nothing to go on you= have nothing to offer. Visibility involves things like logging. You do use logging, don't you? As an extra benefit, the experience of using logs to diagnose a production = issue will provide an object lesson into how useless most programmers are a= t designing logging, and give you insight into proper logging practices. --=20 Lew