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

Memory leak in GroovyScriptEngineImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.2.1
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: