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

PermGen memory leak in ConfigSlurper.parse(Script script, URL location)

    XMLWordPrintableJSON

Details

    Description

      The following will quite quickly result in a java.lang.OutOfMemoryError: PermGen space:

      while(true) {
          new ConfigSlurper().parse("")
      }
      

      This is due to ConfigSlurper.parse(Script script, URL location) modifying meta class of the compiled config script class and not clearing it afterwards which means that there is reference to that class in meta class registry and it never gets garbage collected.

      The exception does not occur for the following:

      while (true) {
          new ConfigSlurper() {
              ConfigObject parse(Script script, URL location) {
                  def config = super.parse(script, location)
                  GroovySystem.metaClassRegistry.removeMetaClass(script.class)
                  config
              }
          }.parse("")
      }
      

      Attachments

        1. GROOVY-7083.png
          97 kB
          Daniel Sun

        Activity

          People

            daniel_sun Daniel Sun
            erdi Marcin Erdmann
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: