0 Replies Latest reply on Jan 12, 2017 4:24 PM by Wenbin Luo

    .Net Hot Rod Client 7.0.0: Memory leak when calling IRemoteCache.GetBulk() in Non-static thread timer process?

    Wenbin Luo Newbie

      Hi,

       

      I found that when calling IRemoteCache.GetBulk() in Non-static thread timer process would cause a memory leak. As long as the process is on, the memory keeps going up. Could someone kindly give some suggestions? Thanks a lot!

      Below is the sample code.

       

      public class InfinispanConnection

      {

                private RemoteCacheManager _rmCacheManager;

                private IRemoteCache<string, string> _remoteCache;

                private System.Threading.Timer _pollCacheTimer;

       

                InfinispanConnection(){

                     try

                     {

                           // Set the Infinispan Client and Database.

                           ConfigurationBuilder  configBuilder = new ConfigurationBuilder();

                           Configuration config = configBuilder .AddServer().Host("127.0.0.1").Port(11222).Build();

                           _rmCacheManager = new RemoteCacheManager(config);

       

                           // Start remote connection to Infinispan Server.

                           _rmCacheManager.Start();

                           _remoteCache = _rmCacheManager.GetCache<string, string>("");

       

                          //Start the Timer

                          _pollCacheTimer= new System.Threading.Timer(PollCache);

                          _pollCacheTimer.Change(0, 5000);

                     }

                     catch (Exception ex)

                     {

                     }

                }

       

                private void PollCache(object notUsed)

                {

                      _pollCacheTimer.Change(Timeout.Infinite, Timeout.Infinite);

                     try

                     {

                          if (_remoteCache != null)

                          {

                               IDictionary<string,string> curData = _remoteCache.GetBulk();

                               foreach (var pointInCache in curData){}

                          }

                     }

                  

                     _pollCacheTimer.Change(0, 5000);

                }

      }

       

      void Main(){

                InfinispanConnection newConn = new InfinispanConnection();

      }