如何修复 SQL Server 程序集优化错误和内存耗尽?

Iai*_*der 9 sql-server-2012

mscorsvw自从我安装了 SQL Server 2012 Service Pack 1 以来,.NET 运行时优化服务 ( ) 一直在消耗我工作站的所有内存。

在耗尽所有可用内存之前,它会消耗大约 1.6 GB 的内存:

.NET 运行时优化服务消耗了我工作站上的所有可用内存。

我可以终止该进程,但是当我重新启动计算机或等待足够长的时间时它会再次发生。

Techdows建议使用 .NET Native Image Generator ( ngen) 来解决该问题。

我打开命令提示符并运行如下命令:

cd C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319.1
ngen executeQueuedItems
Run Code Online (Sandbox Code Playgroud)

的内存消耗mscorsvw下降到大约 20-30 MB,并ngen消耗了所有剩余的内存。

ngen在我终止进程之前只生成错误消息。输出的前几行如下所示:

Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Failed to load dependency Microsoft.DataWarehouse of assembly
Microsoft.SqlServer.MaintenancePlanTasks, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91 because of the following error : The system
cannot find the file specified. (Exception from HRESULT: 0x80070002)
Failed to load dependency Microsoft.VisualStudio.DataTools.Interop of assembly 
Microsoft.DataWarehouse, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91 because of the following error : The system
cannot find the file specified. (Exception from HRESULT: 0x80070002)
Failed to load dependency Microsoft.Data.ConnectionUI of assembly
Microsoft.DataWarehouse, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91 because of the following error : The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)

所有消息都说系统找不到程序集,或者清单定义与引用不匹配。

作为一种解决方法,我已禁用 Windows 服务clr_optimization_v4.0.30319_32clr_optimization_v4.0.30319_64.

这会隐藏问题而不是解决问题,并阻止所有 .NET 程序集进行优化。

我还能尝试什么来解决这个问题?

小智 9

此问题在 Connect 上有所描述(请参阅msiexec.exe 进程在安装 SQL Server 2012 SP1 后继续运行),并且在KB2793634 中提供了一个修补程序。如果您无法立即安装修补程序,则Connect此博客上有关于变通方法的评论。

我选择设置 2 个脚本。第一个脚本每天凌晨 1 点运行,并设置为在执行 1 小时后终止

c:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe executequeueditems
c:\windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe executequeueditems
c:\windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe executequeueditems 
c:\windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe executequeueditems
Run Code Online (Sandbox Code Playgroud)

第二个脚本每天凌晨 3 点运行(以及计算机重新启动时):

c:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe queue pause
c:\windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe queue pause
Run Code Online (Sandbox Code Playgroud)

这样我仍然可以获得编译优化作业(仅在非高峰时段运行),但mscorsvw/msiexec过程已被驯服。