我们正在构建29个用户控件(每个包含许多其他标准和用户控件),它们位于Form上的Load事件处理函数内部。VB.NET WinForms优化使启动更加缓慢
禁用优化(无论是在调试模式下还是在发布模式下的高级编译器设置中),大约需要7秒。启用优化后,这大约需要50秒。这只发生在我们的一台非互联网连接的实验室机器上;我的机器上的启动时间或释放和调试大致相同。我们的目标是Visual Studio 2015中的.NET Framework 4.5 x64。
使用远程调试程序并定期暂停,看起来这是由代码实例化每个用户控件之前使用大量CPU时间的JIT导致的。任何想法可能导致这种情况? JIT功能的
堆栈跟踪,这似乎是采取多数时间:
clrjit.dll!THX_NColBestCoverage(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,class hashBv *,unsigned int,unsigned int,int *,struct CI_TAG *)
clrjit.dll!THX_NColDeterminePhysregAvail(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,class hashBv *,unsigned int,unsigned int,struct tagSYM *,int *,int *,struct CI_TAG *)
clrjit.dll!THX_NColProcessCandidateRegion(struct tagNCOLLIFETIME *,struct tagNCOLREGION *,struct tagNCOLREGION *,struct tagNCOLUSEBENEFITS *,struct tagTUPLE *,int,struct tagNCOLPHYSREGAVAILS *,struct CI_TAG *)
clrjit.dll!THX_NColor(struct tagFUNC *,struct CI_TAG *)
clrjit.dll!THX_dop2_CodegenUpdate(struct tagFUNC *,struct CI_TAG *)
clrjit.dll!THX_dop2(class JitContext *,struct CI_TAG *,unsigned char * *,unsigned int *)
clrjit.dll!PreJit::compileMethod(class ICorJitInfo *,struct CORINFO_METHOD_INFO *,unsigned int,unsigned char * *,unsigned long *)
[Managed to Native Transition]
没有看到负载处理程序中的代码,很难推测。一种可能性,因为这是64位,是负载处理程序中发生的臭名昭着的例外情况。代码是否包含在Try-Catch块中以检测异常?作为一种解决方法,您的代码使用''属性装饰该方法。 –
TnTinMn