Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10529

Re: java.io.File

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: java.io.File
Date 2011-12-05 07:49 -0800
Organization A noiseless patient Spider
Message-ID <jbip72$k7j$1@dont-email.me> (permalink)
References (2 earlier) <5ushd716i6g4qncg620f49ancol20af51f@4ax.com> <20850741.465.1322842636010.JavaMail.geo-discussion-forums@prnu18> <4puhd7h1qgr5rq3cgeebmrt64cc7qfn004@4ax.com> <32687452.648.1322863326052.JavaMail.geo-discussion-forums@prjr26> <8fnpd79eq3grdv0vb4vul24vq5j49os748@4ax.com>

Show all headers | View raw


On 12/5/2011 7:14 AM, Mark wrote:
> Unless the Java class has been badly written we can assume that
> when/if the object is collected then any OS resources that it used
> would also be freed.  Would you agree with this?


Well, the problem here is that not all objects are GC'd in their 
lifetimes.  When the JVM shuts down, no objects are GC'd, the memory 
they occupy is just released.  No finalizers are run.

I've had this happen personally to me.  Forget to close a stream, and 
when the program ends no data is written.  It's still buffered in the 
JVM.  Close your streams and you get data on the disc, like you expected.


> We also see that File does not have a close(), dispose() or similar
> method.  Therefore, if the object does use any OS resources, there is
> no way for the programmer to force them to be released.


The File object represents a path.  It's basically just a String. 
Please stop bringing it up, it's got nothing to do with the issue of OS 
resources.


> On Fri, 2 Dec 2011 14:02:05 -0800 (PST), Lew<lewbloch@gmail.com>
> wrote:
>> 'FileInputStream', but not all 'InputStream' types, and 'FileOutputStream', but
>> not all 'OutputStream' types, do have a 'finalize()' method that might, eventually,
>> release file resources assuming the instances go through two GC cycles, but there's
>> no assurance that that will happen.

> Which, presumably, they have close() methods defined.


Are you sure you're calling close() in all cases?  It sounds like not, 
perhaps you are, but that's the point being made here.


>> Some people believe in Creationism.  It doesn't make their belief valid.
>
> Oh Boy.

He's pointing out that despite references to methods and finalizers, it 
doesn't look like they're being called properly.  We need better 
evidence of what is actually happening to make a better diagnosis of the 
problem.  Everything right now is just guesses and hunches.


> 1. To try to do something even without adequate information.
> 2. Sit on my ass an do nothing until such time as I get more
>     information.
>
> I chose (1).  It sounds like you prefer (2).


"Doing something" should be, imo, making a plan to gather more 
information.  Where can you add logging that will prove, or disprove, 
the current theories about what is happening with the program?

I'm sure there's a unix command to dump resources (like file handles) 
held by each process.  How about dump the out put of that into a file 
before each shell command so we can see who is actually holding on to 
those resources.

Also think about increasing the amount of file handles allowed by the 
JVM or other processes.  The default is actually pretty restrictive and 
designing to stop "abusive" processes.  Really some processes need much 
more.  Don't be afraid to increase it if needed.


Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-02 09:35 +0000
  Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-02 07:25 -0800
    Re: java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-02 15:55 +0000
      Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-02 08:17 -0800
        Re: java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-02 16:31 +0000
          Re: java.io.File markspace <-@.> - 2011-12-02 08:53 -0800
          Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-02 14:02 -0800
            Re: java.io.File Arne Vajhøj <arne@vajhoej.dk> - 2011-12-02 17:12 -0500
              Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-02 14:16 -0800
                Re: java.io.File Arne Vajhøj <arne@vajhoej.dk> - 2011-12-02 18:42 -0500
                Re: java.io.File Lars Enderin <lars.enderin@telia.com> - 2011-12-03 01:06 +0100
                Re: java.io.File Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2011-12-07 15:51 +0200
            Re: java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-05 15:14 +0000
              Re: java.io.File markspace <-@.> - 2011-12-05 07:49 -0800
                Re: java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-05 16:28 +0000
              Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-05 15:25 -0800
                Re: java.io.File Mark <i@dontgetlotsofspamanymore.net> - 2011-12-06 10:29 +0000
          Re: java.io.File Arne Vajhøj <arne@vajhoej.dk> - 2011-12-02 17:08 -0500
      Re: java.io.File Roedy Green <see_website@mindprod.com.invalid> - 2011-12-03 00:57 -0800
    Re: java.io.File Mayeul <mayeul.marguet@free.fr> - 2011-12-02 17:33 +0100
      Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-02 14:07 -0800
        Re: java.io.File Mayeul <mayeul.marguet@free.fr> - 2011-12-06 15:52 +0100
          Re: java.io.File Lew <lewbloch@gmail.com> - 2011-12-06 09:23 -0800

csiph-web