Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-365

LoadCache is retaining strong references to classes and their loaders

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Do
    • Icon: Major Major
    • 3.0.13, 4.0.3
    • 3.0.12, 4.0.2
    • Trigger Injection
    • None

      Class LoadCache keeps a map of known, loaded classes using a nested map hierarchy. The outer map is indexed by classloader and each entry links to a secondary map. The secondary maps are indexed by classname and link to a Class<?> loaded by the corresponding classloader or one of its parents.

      The outer map is a WeakHashMap<ClassLoader, HashMap> which is intended to ensure that entries are released when all references to a loader and its classes have been dropped. However, this is insufficient to achieve this because the inner map is a HashMap<String, Class<?>>. When a inner map M_CL keyed by loaded CL includes an entry for a class C loaded by CL (which is the normal case) then the reference to C from M_CL will keep CL alive, stopping CL from being unloaded.

      The inner maps really need to employ some form of weak reference to the classes embedded in their entries so that this reference cycle can be broken.

              rhn-engineering-adinn Andrew Dinn
              rhn-engineering-adinn Andrew Dinn
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: