You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2015/12/11 22:12:46 UTC

[jira] [Commented] (VFS-512) LRUFilesCache grows arbitrarly

    [ https://issues.apache.org/jira/browse/VFS-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053563#comment-15053563 ] 

Thomas Neidhart commented on VFS-512:
-------------------------------------

The LRUFilesCache does not release files that are attached.

Now, basically any operation on a File object makes it attached, which is a pain.

Changing your test code to this will prevent the cache from growing:

{code}
    public static void visitDirs(FileObject dir) throws FileSystemException {
        // System.out.println(MemoryMeasurer.measureBytes(lruCache));
        FileObject[] files = dir.getChildren();
        dir.close();
        count += files.length;
        for (FileObject f : files) {
            if (f.getType() == FileType.FOLDER) {
                try {
                    visitDirs(f);
                } catch (FileSystemException e) {
                    e.printStackTrace();
                }
            }
            f.close();
        }
    }
{code}

But I think the LRUFileCache should be change to allow also attached files to be removed from the cache. Maybe by first checking if there are any other files to be removed that are not attached.

> LRUFilesCache grows arbitrarly
> ------------------------------
>
>                 Key: VFS-512
>                 URL: https://issues.apache.org/jira/browse/VFS-512
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Bela Hullar
>              Labels: leak
>
> We are experiencing memory issues in our system where we have to scan very big directories. After doing some investigation it turned out that the cause of the issue is the caching of vfs. (http://mail-archives.apache.org/mod_mbox/commons-user/201312.mbox/browser)
> From this reason we tried out LRUFilesCache, but it seems this cache can still grow way beyond the limit. 
> This can be reproduced with a simple test code:
> https://sourceforge.net/p/screeningbee/code/HEAD/tree/trunk/vfs-cache-test/src/main/java/ch/systemsx/bee/vfscachetest/CacheSizeChecker.java
> In this example we set the max size of lru to 100, but running a while this example and then checking the heap of the program showed that the real size of the map can be 10 000 or more too. And it seems its growing constantly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)