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

Memory leak: local variable values are not discarded

    XMLWordPrintableJSON

Details

    Description

      When I run the code below with 3 statements with closures inside the method the local var (parameter) values (all 4 of them) are staying in memory.
      I don't see the same problem if I run corresponding Java code with lambdas.

      Run TestOOM.groovy with
      -Xmx600M -XX:+HeapDumpOnOutOfMemoryError

      Notice groovy fails:
      Y
      Z
      java.lang.OutOfMemoryError: Java heap space
      Dumping heap to java_pid147612.hprof ...
      Heap dump file created [497819587 bytes in 0.136 secs]
      Caught: java.lang.OutOfMemoryError: Java heap space
      java.lang.OutOfMemoryError: Java heap space
          at test.TestOOM.test(TestOOM.groovy:31)
          at test.TestOOM.run(TestOOM.groovy:41)

      But Java version does not.

      It looks like all the values of s are still in memory (see screenshot), even though previous values should be discarded.

      Attachments

        1. groovy_oom.png
          77 kB
          Andriy Rysin
        2. TestOOM_works.groovy
          0.6 kB
          Andriy Rysin
        3. TestOOM.groovy
          0.5 kB
          Andriy Rysin
        4. TestOOMIcj.java
          0.9 kB
          Andriy Rysin
        5. TestOOMJ.java
          0.6 kB
          Andriy Rysin

        Activity

          People

            emilles Eric Milles
            arysin Andriy Rysin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: