commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ima...@apache.org>
Subject Re: [VFS] FileSystem close
Date Thu, 08 Jul 2004 11:22:04 GMT
Mail from Johan - Forwarded to the mailinglist too

Mario



On Wed, 07 Jul 2004 22:20:12 +0200, Mario Ivankovits 
<imario@apache.org>  wrote:

> So i picked up the SoftRefFilesCache and adapted it slightly.
>
> The idea behind is - as long as a FileObject is "strongly reachable" 
> by  the jvm there must be someone who is willing to access the file 
> and thus  it is not allowed to close the filesystem.
> As soon as the last file of a certain filesystem is garbage-collected  
> the filesystem can be (and will be) closed.
>
> For sure - now you do not have that control over this release 
> process,  but it should work well.



Much better idea - a small problem may be that garbage collection can 
not  be forced and resources could potentially build up substantially 
before  they are cleared ...


> One has simply to ensure to release all references (assign null to it 
> if  it is a global member) to make this work.
>
> @Johan:
> I would like to remove the useCount (freeUnusedResources) stuff from 
> vfs  again. Could you please try this in your environment.
>
> Instantiate your vfs manager like this:
>
> StandardFileSystemManager manager = new StandardFileSystemManager();
> manager.setFilesCache(new SoftRefFilesCache());
> manager.init();
>
> and remove the call to freeUnusedResources - and - as long as you do 
> not  use any input/output stream - the FileObject.close() is also no 
> longer  needet.



Have tried this and it's working fine - had to "suggest" GC a couple of  
times, but the references (and therefore the session) disappear after a  
while - excellent :)

Cheers,

Johan


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message