Excel的进程的最大数目?数目、进程、最大、Excel

2023-09-05 00:50:03 作者:浅笑半离汐

如果我这样做(例如)

 的for(int i = 0; I< 22;我++)
 {
     VAR应用=新Excel.Application();
 }
 

22,然后Excel的过程中创建的。

但是,如果我这样做

 的for(int i = 0;我α25;我++)
 {
     VAR应用=新Excel.Application();
 }
 
EXCEL 分类统计数量

它创建22练成的过程,但随后大多dissapear,只有少数留下。

有22或什么限制?这个问题能增加多少?

谢谢!

编辑:用以下code就不会发生:

  VAR应用程序=新的List<应用>();
 的for(int i = 0;我α25;我++)
 {
      apps.Add(新的应用程序());
 }
 

解决方案

垃圾收集踢......与以下code,它的工作原理:

  VAR应用程序=新的List<应用>();
 的for(int i = 0;我α25;我++)
 {
      apps.Add(新的应用程序());
 }
 

If I do (for example)

 for (int i=0;i<22;i++)
 {
     var app = new Excel.Application();
 }

then 22 excel processes are created.

However, if I do

 for (int i=0;i<25;i++)
 {
     var app = new Excel.Application();
 }

It creates 22 excel processes, but then most of them dissapear and only a few are left.

Is there a limit of 22 or something? Can this be increased?

Thanks!

EDIT: with following code it doesn't occur:

 var apps = new List<Application>();
 for (int i=0;i<25;i++)
 {
      apps.Add(new Application());
 }

解决方案

Garbage collection kicked in... with following code, it works:

 var apps = new List<Application>();
 for (int i=0;i<25;i++)
 {
      apps.Add(new Application());
 }