Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-240

Severe memory leak in TreeCache when path does not exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.8.0
    • 2.9.0
    • Recipes
    • java version "1.7.0_71"
      Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

      OSX Yosemite

    Description

      When creating a TreeCache, if the path supplied does not exist in Zookeeper then the heap is quickly exhausted. The problem appears to be instances of org.apache.curator.framework.imps.NamespaceWatcher.

      Try running the following test:

      package org.apache.curator.framework.recipes.cache;
      
      import org.apache.curator.framework.CuratorFramework;
      import org.apache.curator.framework.CuratorFrameworkFactory;
      import org.apache.curator.framework.recipes.cache.TreeCache;
      import org.apache.curator.retry.RetryOneTime;
      import org.apache.curator.test.TestingServer;
      
      public class TreeCacheLeak {
      
          public static void main(String[] args) throws Exception {
      
              TestingServer server = new TestingServer();
              
              final CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
              curatorFramework.start();
      
              final TreeCache cache = new TreeCache(curatorFramework, "/foo/bar/baz");
              cache.start();
      
              try {
                  while (true) {
                      Thread.sleep(1000);
                  }
              } finally {
                  cache.close();
                  server.close();
              }
          }
      
      }
      

      Launch the class then connect e.g. jvisualvm. You'll see the heap growing and if you watch for a few minutes then take a heap dump, you'll see millions of instances of org.apache.curator.framework.imps.NamespaceWatcher are present.

      Attachments

        Activity

          People

            dragonsinth Scott Blum
            japher Joe Littlejohn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: