You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Peter Lee <pe...@gmail.com> on 2020/06/29 01:34:48 UTC

[VFS] VFS-748 : about files cache

Hi all,

As the issue VFS-748 said, it seems there's a problem in TarFileSystem
about the files cache : it will be removed after a JVM gc.

I looked into the code and found out that the cache is held by the local
variable strongRef :  the variable strongRef and the variable fileObj are
holding each other. I believe this cross-reference design here is to avoid
the JVM gc on them - and it seems it's not working(I'm using JDK8). BTW the
same cross-reference design also exists in ZipFileSystem, and it's also not
working - we could remove the variable strongRef in ZipFileSystem and the
gc is not working on it. Not sure why it's like this.

So why do we make the variable strongRef a local variable here in
TarFileSystem? We could simply make it a private field of the class
TarFileSystem and the garbage collector would no longer work here - this
issue could simply be fixed(and my fix is in branch VFS-748 of my forked
repo https://www.github.com/PeterAlfredLee/commons-vfs). From my view this
is a simple fix.

Are there some other reasons limiting the variable strongRef to be a local
variable instead of a private field here? It's appreciated if someone could
tell me - seems this code was written back in 2005 by the git log.

cheers,
Lee