[
https://issues.apache.org/jira/browse/GROOVY-3476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149606#comment-18149606
]
ASF GitHub Bot commented on GROOVY-3476:
----------------------------------------
blackdrag commented on PR #3347:
URL: https://github.com/apache/groovy/pull/3347#issuecomment-7094172313
@daniellansun The issue was about a memory leak if you use `groovy -l`. Your
solution approach is to reuse the class we compiled before. But the PR confuses
me. How is there a file to reuse if the script comes in as expression? Also
what happens if we send a different script each time? For example with `groovy
-e "def n =0; while (true) { n++; new Socket('localhost',5000).outputStream <<
n+'\n'}"` Then you will not be reusing the existing script anymore, and if the
issue still holds, this will run out of memory.
> groovy -l constantly loads classes and leaks memory
> ---------------------------------------------------
>
> Key: GROOVY-3476
> URL: https://issues.apache.org/jira/browse/GROOVY-3476
> Project: Groovy
> Issue Type: Bug
> Components: command line processing
> Affects Versions: 1.6.1, 2.1.2
> Environment: Linux, Solaris, and Cygwin, at least
> Reporter: J. David Beutel
> Assignee: Daniel Sun
> Priority: Major
>
> The classes loaded by a -l script keep increasing until the JVM runs out of
> memory. I saw this with a script file, but it also can be demonstrated with
> two command lines:
> {code}
> JAVA_OPTS="-Xmx5m" groovy -l 5000 -e "System.err.println
> java.lang.management.ManagementFactory.classLoadingMXBean.loadedClassCount" &
> groovy -e "while (true) { new Socket('localhost',5000).outputStream << '\n'}"
> {code}
> As a work-around, I used a ServerSocket instead of groovy -l.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)