InputStream caching

  • Marcin Werla

    Marcin Werla - 2005-04-22


    I use JavaDjvu for extracting and indexing text from DjVu files. I've found that, there is a cache for opened streams DjVuPage class (static field cache). I have disabled this cache by subclassing DjVuPage class - it is necassary for me, as I open thousands of files in one "session" - and all of them were cached.

    And here is my question: is there somewhere else another caching mechanism which I should disable?

    Marcin Werla

    • Dr Bill C Riemers

      Rather commenting out the cache mechanism, instead change the HashTable to a WeakHashMap. That way files which are still in use will not need to be reloaded. Even better add a GList of SoftReferences to append streams to, so the data will be available until the garbage collector determines the memory is needed.

      I would have designed the caching this way, but this solution is not Java 1.1 compatible.


    • Dr Bill C Riemers

      You will find in the 0.8.03 and 0.8.04 versions SoftReferences are used for caching on modern Java versions, and only minimal caching is done with older Java versions.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks