Maximum number of excel processes?

人盡茶涼 提交于 2019-12-13 14:42:59

问题


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());
 }

回答1:


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());
 }



回答2:


I remember an article by Raymond Chen. Something about if you load too many of the same process for your specific machine, the OS cuts you off. It's different for every machine (as it's based on the performance of your machine).

However, I can't see 25 as being a limit. That seems slightly too small, even for older machines. Are any of your files referencing data from the same files causing some of them to close prematurely because another instance of Excel is locking the file?

I'd need more information to find out what is actually going on.



来源:https://stackoverflow.com/questions/11158971/maximum-number-of-excel-processes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!