class Program
   {
       static void Main(string[] args)
       {
           var all = new List<string>();
           for (var i = 0; i < 999999999999; i++)
           {
               var b = new List<string>();

               for (var j = 0; j < 1000; j++)
               {
                   b.Add(new Guid().ToString());

                   try
                   {
                       all.AddRange(b);
                   }
                   catch (Exception)
                   {
                       Console.WriteLine(all.Count);

                   }
               }

           }

           Console.WriteLine(all.Count);

       }
   }

 

 

C# 使用List<T> 内存溢出

相关文章:

猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-05-15
  • 2021-08-14
相关资源
相似解决方案