當前位置: 首頁>>代碼示例>>C#>>正文


C# REngine.ForceGarbageCollection方法代碼示例

本文整理匯總了C#中RDotNet.REngine.ForceGarbageCollection方法的典型用法代碼示例。如果您正苦於以下問題:C# REngine.ForceGarbageCollection方法的具體用法?C# REngine.ForceGarbageCollection怎麽用?C# REngine.ForceGarbageCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RDotNet.REngine的用法示例。


在下文中一共展示了REngine.ForceGarbageCollection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReproWorkitem43

 private static void ReproWorkitem43(REngine engine)
 {
     Random r = new Random(0);
      int N = 500;
      int n1 = 207;
      int n2 = 623;
      var arGroup1Intensities = new double[N][];
      var arGroup2Intensities = new double[N][];
      for (int i = 0; i < N; i++)
      {
     arGroup1Intensities[i] = new double[n1];
     arGroup2Intensities[i] = new double[n2];
     for (int j = 0; j < n1; j++)
        arGroup1Intensities[i][j] = r.NextDouble();
     for (int j = 0; j < n2; j++)
        arGroup2Intensities[i][j] = r.NextDouble();
      }
      var res = new GenericVector[N];
      NumericVector vGroup1, vGroup2;
      for (int i = 0; i < N; i++)
      {
     vGroup1 = engine.CreateNumericVector(arGroup1Intensities[i]);
     Console.WriteLine(vGroup1.Length);
     if (i % 10 == 4)
     {
        engine.ForceGarbageCollection();
        engine.ForceGarbageCollection();
     }
     vGroup2 = engine.CreateNumericVector(arGroup2Intensities[i]);
     Console.WriteLine(vGroup2.Length);
     engine.SetSymbol("group1", vGroup1);
     engine.SetSymbol("group2", vGroup2);
     GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList();
     res[i] = testResult;
      }
 }
開發者ID:jmp75,項目名稱:rdotnet-support,代碼行數:36,代碼來源:Program.cs

示例2: ReproDiscussion532760

        private static void ReproDiscussion532760(REngine engine)
        {
            // https://rdotnet.codeplex.com/discussions/532760
             //> x <- data.frame(1:1e6, row.names=format(1:1e6))
             //> object.size(x)
             //60000672 bytes
             //> object.size(rownames(x))
             //56000040 bytes

             engine.Evaluate("x <- data.frame(1:1e6, row.names=format(1:1e6))");
             var x = engine.GetSymbol("x").AsDataFrame();
             engine.ForceGarbageCollection();
             engine.ForceGarbageCollection();
             var memoryInitial = engine.Evaluate("memory.size()").AsNumeric().First();

             var netMemBefore = GC.GetTotalMemory(true);

             var blah = x.RowNames;
             //var blah = engine.Evaluate("rownames(x)").AsCharacter().ToArray();
             blah = null;

             GC.Collect();
             engine.ForceGarbageCollection();
             engine.ForceGarbageCollection();
             var memoryAfterAlloc = engine.Evaluate("memory.size()").AsNumeric().First();

             var netMemAfter = GC.GetTotalMemory(false);
        }
開發者ID:jmp75,項目名稱:rdotnet-support,代碼行數:28,代碼來源:Program.cs


注:本文中的RDotNet.REngine.ForceGarbageCollection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。