Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6191

Memory leak in GroovyScriptEngineImpl

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.3
    • Fix Version/s: 2.2.1
    • Component/s: None
    • Labels:
      None

      Description

      Previously evaluation of the same script (but different String instances) led to reading script class from cache, now if different String instances are used for script text, the value is not found in cache, so that script engine compiles the same script again and adds new Class instance to the classMap.

      This leads to inefficient caching, and also may cause memory leak.

      Please consider the following code sample:

        e = new org.codehaus.groovy.jsr223.GroovyScriptEngineImpl()
        println e.eval('System.identityHashCode(this.getClass())')
        println e.eval('System.identityHashCode(this.getClass())')
        println e.eval(new String('System.identityHashCode(this.getClass())'))
      

      In groovy 1.7 it produced 3 identical lines in output.
      In groovy 2.1.3 the third line differs from previous two.

        Attachments

          Activity

            People

            • Assignee:
              blackdrag Jochen Theodorou
              Reporter:
              enterit Sergey Bondarenko
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: