curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavan Kumar M S (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CURATOR-312) Memory leak of NamespaceWatcher when register TreeCacheListener to non-existing path
Date Fri, 25 Mar 2016 07:07:25 GMT

    [ https://issues.apache.org/jira/browse/CURATOR-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15211524#comment-15211524
] 

Pavan Kumar M S commented on CURATOR-312:
-----------------------------------------

 num     #instances         #bytes  class name
----------------------------------------------
   1:      30778219      984903008  java.util.HashMap$Node
   2:      30523671      732568104  org.apache.curator.framework.imps.NamespaceWatcher
   3:         69676      477280544  [Ljava.util.HashMap$Node;


> Memory leak of NamespaceWatcher when register TreeCacheListener to non-existing path
> ------------------------------------------------------------------------------------
>
>                 Key: CURATOR-312
>                 URL: https://issues.apache.org/jira/browse/CURATOR-312
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.8.0
>         Environment: Suse Linux + JDK 1.8 
> Windows 7 + JDK 1.7
>            Reporter: Pavan Kumar M S
>             Fix For: awaiting-response
>
>
> Hi, 
>     
>      As per the Curator API document its allowed to register the TreeCacheListener to
the path which is not present in the broker, but when we try to register its found that object
'NamespaceWatcher' keep on increasing and leading to out of memory in very short time. 
>    Following is the sample code which can be used to reproduce the issue. 
> import org.apache.curator.framework.CuratorFramework;
> import org.apache.curator.framework.CuratorFrameworkFactory;
> import org.apache.curator.framework.CuratorFrameworkFactory.Builder;
> import org.apache.curator.framework.recipes.cache.TreeCache;
> import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
> import org.apache.curator.framework.recipes.cache.TreeCacheListener;
> import org.apache.curator.retry.RetryNTimes;
> public class TreeCacheProblem
> {
>     private static final int RETRYTIMES = 3;
>     private static final int RETRYINTERVAL = 1000;
>     private static final int CONNECTION_TIME_OUT = 3000;
>     private static final int SESSION_TIME_OUT = 5000;
>     public static void main ( String [] args ) throws Exception
>     {
>         TreeCacheProblem treeCache = new TreeCacheProblem();
>         treeCache.init ( "10.18.104.149:2189" );
>         String zkPath = "/home/sample";
>         treeCache.addTreeCacheListener ( zkPath, new TreeCacheListener(){
>             public void childEvent ( CuratorFramework client, TreeCacheEvent event )
>                 throws Exception
>             {
>                  System.out.println (event);
>             }
>         });
>         System.in.read();
>     }
>     private CuratorFramework client;
>     private void init ( String zkURL )
>     {
>         Builder connect = CuratorFrameworkFactory.builder ().connectString ( zkURL );
>         this.client = connect.retryPolicy ( new RetryNTimes ( RETRYTIMES, RETRYINTERVAL
) )
>             .connectionTimeoutMs ( CONNECTION_TIME_OUT ).sessionTimeoutMs ( SESSION_TIME_OUT
)
>             .build ();
>         this.client.start ();
>     }
>     public void addTreeCacheListener ( String zkPath, TreeCacheListener treeCacheListener
) throws Exception
>     {
>         org.apache.curator.framework.recipes.cache.TreeCache.Builder builder = TreeCache
>             .newBuilder ( client, zkPath );
>         builder.setCacheData ( true );
>         TreeCache treeCache = builder.build ();
>         treeCache.getListenable ().addListener ( treeCacheListener );
>         treeCache.start ();
>     }
> }
> With Regards,
> Pavan



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message