Return-Path: X-Original-To: apmail-curator-dev-archive@minotaur.apache.org Delivered-To: apmail-curator-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EEB7119B63 for ; Fri, 25 Mar 2016 07:07:25 +0000 (UTC) Received: (qmail 1686 invoked by uid 500); 25 Mar 2016 07:07:25 -0000 Delivered-To: apmail-curator-dev-archive@curator.apache.org Received: (qmail 1596 invoked by uid 500); 25 Mar 2016 07:07:25 -0000 Mailing-List: contact dev-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list dev@curator.apache.org Received: (qmail 1555 invoked by uid 99); 25 Mar 2016 07:07:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Mar 2016 07:07:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7F9DD2C14DC for ; Fri, 25 Mar 2016 07:07:25 +0000 (UTC) Date: Fri, 25 Mar 2016 07:07:25 +0000 (UTC) From: "Pavan Kumar M S (JIRA)" To: dev@curator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CURATOR-312) Memory leak of NamespaceWatcher when register TreeCacheListener to non-existing path MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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)