我們正在構建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