jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Janino
  • JANINO-88

JavaSourceClassLoader has a memory leak for JavaSourceIClassLoader.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Reopened Reopened
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Labels:
    None

Description

JavaSourceClassLoader creates a singleton JavaSourceIClassLoader in it's constructor. This is actually a cause for a memory leak in long-running server processes. The simplest fix is to create a new JavaSourceIClassLoader each time in generateByteCodes.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    fix_JavaSourceClassLoader-memleak.patch
    13/May/07 9:22 PM
    5 kB
    Adam Heath

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Arno Unkrig added a comment - 18/May/07 4:42 PM

I'm not happy with that change. The important lines of code are:

JavaSourceClassLoader.java line 404
/**
     * Collection of parsed, but uncompiled compilation units.
     */
    private final Set unitCompilers = new HashSet(); // UnitCompiler

If I apply your change, then JSCL will no longer keep parsed but uncompiled CUs. That's probably a HUGE performance hit!

Anyway, why do you consider the singleton JSICL a memory leak? It is only references by the JSCL, and hence freed if the JSCL is GCed.

Show
Arno Unkrig added a comment - 18/May/07 4:42 PM I'm not happy with that change. The important lines of code are:
JavaSourceClassLoader.java line 404
/**
     * Collection of parsed, but uncompiled compilation units.
     */
    private final Set unitCompilers = new HashSet(); // UnitCompiler
If I apply your change, then JSCL will no longer keep parsed but uncompiled CUs. That's probably a HUGE performance hit! Anyway, why do you consider the singleton JSICL a memory leak? It is only references by the JSCL, and hence freed if the JSCL is GCed.
Hide
Permalink
Adam Heath added a comment - 20/May/07 3:04 PM

When would the JSCL be GCed, exactly? It won't, until the classes that were loaded by it were all GCed. All classes loaded by the VM maintain a reference back to their loading ClassLoader. If a class happened to be added into a ThreadLocal, and the ThreadLocal is maintained statically in a class not dynamically loaded, then everything underneath JSCL will never be freed.

I found this issue, while tracking down several memory leaks in a long-running server process. Made use of jconsole and jhat in java 1.6.

Show
Adam Heath added a comment - 20/May/07 3:04 PM When would the JSCL be GCed, exactly? It won't, until the classes that were loaded by it were all GCed. All classes loaded by the VM maintain a reference back to their loading ClassLoader. If a class happened to be added into a ThreadLocal, and the ThreadLocal is maintained statically in a class not dynamically loaded, then everything underneath JSCL will never be freed. I found this issue, while tracking down several memory leaks in a long-running server process. Made use of jconsole and jhat in java 1.6.
Hide
Permalink
Arno Unkrig added a comment - 12/Jun/07 2:10 PM

When would the JSCL be GCed, exactly? It won't, until the classes that were loaded by it were all GCed. All classes loaded by the VM maintain a reference back to their loading ClassLoader. If a class happened to be added into a ThreadLocal, and the ThreadLocal is maintained statically in a class not dynamically loaded, then everything underneath JSCL will never be freed.

Yes, but that's only natural! When the last class loaded through the JSCL is GCd, then the JSCL and the JSICL are also available for GC. That's not a memory leak. The resources held by the JSICL (esp. "unitCompilers") are used in case another class needs to be loaded through the JSCL.

Am I missing anything?

CU

Arno

Show
Arno Unkrig added a comment - 12/Jun/07 2:10 PM
When would the JSCL be GCed, exactly? It won't, until the classes that were loaded by it were all GCed. All classes loaded by the VM maintain a reference back to their loading ClassLoader. If a class happened to be added into a ThreadLocal, and the ThreadLocal is maintained statically in a class not dynamically loaded, then everything underneath JSCL will never be freed.
Yes, but that's only natural! When the last class loaded through the JSCL is GCd, then the JSCL and the JSICL are also available for GC. That's not a memory leak. The resources held by the JSICL (esp. "unitCompilers") are used in case another class needs to be loaded through the JSCL. Am I missing anything? CU Arno
Hide
Permalink
Arno Unkrig added a comment - 25/Dec/07 3:58 PM

No activity on this one.

Show
Arno Unkrig added a comment - 25/Dec/07 3:58 PM No activity on this one.
Hide
Permalink
Adam Heath added a comment - 20/Aug/08 10:17 PM

A memory leak is not just something that can't be freed due to self referential loops. There's no need to keep the iClassLoader around after the classes have been parsed/compiled. Disconnecting this allows more memory to be freed earlier(freeing iClassLoader), so that it is available to the rest of the system.

Sorry for taking so long to get back; got busy with work, and forgot about checking back.

Show
Adam Heath added a comment - 20/Aug/08 10:17 PM A memory leak is not just something that can't be freed due to self referential loops. There's no need to keep the iClassLoader around after the classes have been parsed/compiled. Disconnecting this allows more memory to be freed earlier(freeing iClassLoader), so that it is available to the rest of the system. Sorry for taking so long to get back; got busy with work, and forgot about checking back.

People

  • Assignee:
    Matt Fowles
    Reporter:
    Adam Heath
Vote (0)
Watch (0)

Dates

  • Created:
    13/May/07 9:22 PM
    Updated:
    21/Dec/09 8:59 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.