简体   繁体   中英

NGen ASP.NET to save memory - Native Image not used

We have a web application which we host, where we deploy the same application to 100+ "tenants" on the same machine(s). Managed DLL's memory is not shared between processes by default, that means we load the same DLL 100+ times into memory. Goal is to avoid this, and NGen seems to be the way to go for this, as it specifically allows this to happen.

The ASP.NET application is pre-compiled and all DLL's have been NGen'ed, but it seems that they are not used.

Fusion Log Viewer gives us the following output:

* Assembly Binder Log Entry (20.06.2017 @ 16:53:11) *

The operation was successful. Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from: C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\clr.dll Running under executable c:\\windows\\system32\\inetsrv\\w3wp.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = SD.LLBLGen.Pro.ORMSupportClasses, Version=5.1.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27 (Fully-specified) LOG: Appbase = file:///E:/WebHotel/tenant/ItemService/ LOG: Initial PrivatePath = E:\\WebHotel\\tenant\\ItemService\\bin LOG: Dynamic Base = E:\\Temporary ASP.NET Files\\itemservice\\081f93f5 LOG: Cache Base = E:\\Temporary ASP.NET Files\\itemservice\\081f93f5 LOG: AppName = fd860966 Calling assembly : Product.Core.Library, Version=2.5.12456.0, Culture=neutral, PublicKeyToken=null. === LOG: IL assembly loaded from E:\\Temporary ASP.NET Files\\itemservice\\081f93f5\\fd860966\\assembly\\dl3\\08cf29cf\\00893e3e_afe9d201\\SD.LLBLGen.Pro.ORMSupportClasses.dll.

* Assembly Binder Log Entry (20.06.2017 @ 16:53:11) *

The operation was successful. Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from: C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\clr.dll Running under executable c:\\windows\\system32\\inetsrv\\w3wp.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = SD.LLBLGen.Pro.ORMSupportClasses, Version=5.1.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27 (Fully-specified) LOG: Appbase = file:///E:/WebHotel/tenant/ItemService/ LOG: Initial PrivatePath = E:\\WebHotel\\tenant\\ItemService\\bin LOG: Dynamic Base = E:\\Temporary ASP.NET Files\\itemservice\\081f93f5 LOG: Cache Base = E:\\Temporary ASP.NET Files\\itemservice\\081f93f5 LOG: AppName = fd860966 Calling assembly : Product.Core.Library, Version=2.5.12456.0, Culture=neutral, PublicKeyToken=null. === LOG: IL assembly loaded from E:\\Temporary ASP.NET Files\\itemservice\\081f93f5\\fd860966\\assembly\\dl3\\08cf29cf\\00893e3e_afe9d201\\SD.LLBLGen.Pro.ORMSupportClasses.dll.

As you can see it does not load the native image from C:\\Windows\\assembly\\NativeImages_v4.0.30319_64 ...

Using: NGen display "SD.LLBLGen.Pro.ORMSupportClasses, Version=5.1.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"

gives us:

C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319>ngen display "SD.LLBLGen.Pro.ORM SupportClasses, Version=5.1.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff2 7" Microsoft (R) CLR Native Image Generator - Version 4.6.1087.0 Copyright (c) Microsoft Corporation. All rights reserved.

NGEN Roots:

\\server\\e$\\Template\\2.5.12456.0\\ItemService\\bin\\SD.LLBLGen.Pro.ORMSuppor NGEN Roots that depend on "SD.LLBLGen.Pro.ORMSupportClasses, Version=5.1.0.0, Cu lture=neutral, PublicKeyToken=ca73b74ba4e3ff27":

\\server\\e$\\Template\\2.5.12456.0\\WS\\bin\\SD.LLBLGen.Pro.ORMSupportClasse s.dll

Native Images:

SD.LLBLGen.Pro.ORMSupportClasses, Version=5.1.0.0, Culture=neutral, PublicKeyTok en=ca73b74ba4e3ff27

Not sure if this is the issue, but c:\\windows\\system32\\inetsrv\\w3wp.exe seems to be a 32-bit executable, and you're using the 64-bit ngen.exe . If your app is 32-bit, you'll need to use the 32-bit ngen.exe , or the 64-bit w3wp.exe if it's the other way around.

If this is not the issue, you may want to check this blog post (if you haven't already):
https://kceiw.me/net-native-image-troubleshooting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM