Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-320

Add LruCacheClassPathRepository that can scan many JAR files without OutOfMemoryError

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 6.4.0
    • None
    • None

    Description

      (This ticket is derivation from BCEL-317, which I found creating ConstantUtf8 cache is not straightforward under current ClassPathRepository design.)

      We use BCEL library in https://github.com/GoogleCloudPlatform/cloud-opensource-java . Thank you for great library.

      Background

      Our use of BCEL ClassPathRepository and MemorySensitiveClassPathRepository causes OutOfMemoryError when they scan many (~200) JAR files. Initially I thought this problem could be fixed by BCEL-317, but it turned out that it's not straightforward under current design. Instead of focusing on ConstantUtf8, I decided to use my own custom ClassPathRepository that uses LRU cache internally to hold JavaClass instances. It worked.

      This ticket is to contribute the idea to BCEL library so that other users can benefit from it.

      Test Case

      This GitHub project is a example of OutOfMemoryError caused by scanning many JAR files using BCEL ClassPathRepository and MemorySensitiveClassPathRepository:

      https://github.com/suztomo/bcel-oome-example

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              suztomo Tomo Suzuki
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m