Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-31435

Replace String.intern() by WeakHashMap in Maven Plugin to avoid memory leaks

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • None

      The issue has been discovered by schristou

      Ok after doing far more investigating on this issue I found out that actually the String.intern() in JDK7 actually uses a String pool to handle the strings. It does not go to pergmen (See http://bugs.java.com/view_bug.do?bug_id=6962931). See also http://java-performance.info/string-intern-in-java-6-7-8/.

      I remember investigating their memory leak issue and I found it to be related to the ModuleDependency in the maven plugin. If you look at: https://github.com/jenkinsci/maven-plugin/blob/master/src/main/java/hudson/maven/ModuleDependency.java#L111

      We are doing a String.intern on the version number which I'd assume consumes the String pool. If we're interning the version number for each maven project I bet this could cause a memory leak fairly quick. The reason why is if I create a new version number for each build (continuous delivery), then I'm interning the string each time.

      Such memory leak may happen in GCs like ParallelGC: http://stackoverflow.com/questions/2431540/garbage-collection-behaviour-for-string-intern .

          [JENKINS-31435] Replace String.intern() by WeakHashMap in Maven Plugin to avoid memory leaks

          Oleg Nenashev created issue -
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 166799 ] New: JNJira + In-Review [ 182473 ]
          CloudBees Inc. made changes -
          Remote Link New: This issue links to "CloudBees Internal OSS-332 (Web Link)" [ 18911 ]

            Unassigned Unassigned
            oleg_nenashev Oleg Nenashev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: