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

ASF GitHub Bot commented on GEODE-9171:
---------------------------------------

mmartell commented on a change in pull request #786:
URL: https://github.com/apache/geode-native/pull/786#discussion_r617642550



##########
File path: clicache/integration-test2/GarbageCollectCache.cs
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+    [Trait("Category", "Integration")]
+    public class GarbageCollectCache : TestBase
+    {
+        public GarbageCollectCache(ITestOutputHelper testOutputHelper) : 
base(testOutputHelper)
+        {
+        }
+
+        [Fact]
+        public void VerifyNoLeakedThreads()
+        {
+            using (var cluster = new Cluster(output, 
CreateTestCaseDirectoryName(), 1, 1))
+            {
+                Assert.True(cluster.Start());
+                Assert.Equal(0, cluster.Gfsh
+                    .create()
+                    .region()
+                    .withName("testRegion")
+                    .withType("PARTITION")
+                    .execute());
+
+                for (int i=0; i<25; i++)
+                {
+                    var ncThreadsBefore = 
Process.GetCurrentProcess().Threads.Count;
+
+                    using (var cache = new CacheFactory()
+                        .Set("log-level", "none")
+                        .Create())
+                    {
+
+                        
cluster.ApplyLocators(cache.GetPoolFactory()).Create("default");
+
+                        var regionFactory = 
cache.CreateRegionFactory(RegionShortcut.PROXY)
+                            .SetPoolName("default");
+
+                        var region = regionFactory.Create<string, 
string>("testRegion");
+
+                        const string key = "hello";
+                        const string expectedResult = "dave";
+
+                        region.Put(key, expectedResult);
+                        var actualResult = region.Get(key);
+                        Assert.Equal(expectedResult, actualResult);
+
+                        cache.Close();
+                    }
+
+                    var ncThreadsAfter = 
Process.GetCurrentProcess().Threads.Count;
+                    var ratio = ncThreadsBefore / (double)ncThreadsAfter;
+
+                    // Because the number of threads in the process depends on
+                    // the number of cores, debug vs release, whether the GC 
thread
+                    // is running, etc., a robust test is to check whether the 
ratio
+                    // of before and after threads is close to one. Also 
skipping the
+                    // first couple of iterations avoids threads related to 
test 
+                    // environment startup.
+                    if (i > 5)
+                    {
+                        //Assert.True(.8 < ratio && ratio < 1.3);
+                        string error = "ncThreadsBefore = " + 
ncThreadsBefore.ToString() +
+                            ", ncThreadsAfter = " + ncThreadsAfter.ToString();
+                        Assert.False(!(.8 < ratio && ratio < 1.3), error);
+                    }
+                }
+            }
+        }
+
+        [Fact(Skip = "Need a heuristic to filter out GC effect.")]

Review comment:
       Removing until we can come up with a heuristic that works properly in 
the CI.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Threads Aren't Being Terminated
> -------------------------------
>
>                 Key: GEODE-9171
>                 URL: https://issues.apache.org/jira/browse/GEODE-9171
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>            Reporter: Michael Martell
>            Priority: Major
>              Labels: pull-request-available
>
> For .NET applications using the native client, threads aren't being 
> terminated when the native client Cache is closed. This causes a huge leak of 
> memory which can cause long running apps to crash.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to