MSSQL 2014: XML: 無法建立 XML 文件,因為伺服器記憶體不足。請使用 sp_xml_removedocument 釋放 XML 文件

Microsoft.SQLServer.2014.XML___XML_document_could_not_be_created_because_server_memory_is_low._Use_sp_xml_removedocument_to_release_XML_documents_1_5_Rule (Rule)

執行 sp_xml_preparedocument 時,剖析的 XML 文件會儲存在 SQL Server 2000 的內部快取。MSXML 剖析器對 SQL Server 最多會使用可用記憶體總計的八分之一。配置給 MSXML 的快取部分的記憶體不足,無法開啟 sp_xml_preparedocument 陳述式中所指定的文件。原因可能是指定的文件非常大,或已在該記憶體空間中的文件,沒有足夠的空間可放置新文件。

Knowledge Base article:

摘要

當您執行 sp_xml_preparedocument 時,剖析的 XML 文件會儲存在 SQL Server 2000 的內部快取。MSXML 剖析器使用 SQL Server 可用總記憶體的最多八分之一。在配置給 MSXML 的快取部分中沒有足夠的記憶體可開啟 sp_xml_preparedocument 陳述式中指定的文件。這可能是因為指定的文件很大,或是因為已在該記憶體空間中的文件沒有足夠的空間給新文件使用。

如需剖析 XML 文件的詳細資訊,請參閱《線上叢書》中的<sp_xml_preparedocument>與<sp_xml_removedocument>。

解決方式

請執行 sp_xml_removedocument 從記憶體移除文件。請驗證您的程式碼一律會在完成處理文件時呼叫 sp_xml_removedocument。您的程式碼應該負責處理 sp_xml_preparedocumentsp_xml_removedocument 呼叫之間連線或交易遭到中斷的可能性。要完成此動作,您可能需要將開啟文件控點,儲存在可以在批次遭到中斷時參照的資料表中。

可覆寫的參數

名稱

描述

預設值

已啟用

啟用或停用該工作流程。

優先順序

定義警示優先順序。

1

嚴重性

定義警示嚴重性。

1

Element properties:

TargetMicrosoft.SQLServer.2014.DBEngine
CategoryEventCollection
EnabledTrue
Event_ID6624
Event Source$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/ServiceName$
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
RemotableTrue
Alert Message
MSSQL 2014: XML: 無法建立 XML 文件,因為伺服器記憶體不足。請使用 sp_xml_removedocument 釋放 XML 文件
{0}
Event LogApplication
CommentMom2014ID='{136A2E5E-A460-4FAE-8587-D72C945E89EB}';MOM2014GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}

Member Modules:

ID Module Type TypeId RunAs 
_F6DA1507_12AF_11D3_AB21_00A0C98620CE_ DataSource Microsoft.Windows.EventProvider Default
GenerateAlert WriteAction System.Health.GenerateAlert Default

Source Code:

<Rule ID="Microsoft.SQLServer.2014.XML___XML_document_could_not_be_created_because_server_memory_is_low._Use_sp_xml_removedocument_to_release_XML_documents_1_5_Rule" Target="SQL2014Core!Microsoft.SQLServer.2014.DBEngine" Enabled="true" ConfirmDelivery="true" Remotable="true" Comment="Mom2014ID='{136A2E5E-A460-4FAE-8587-D72C945E89EB}';MOM2014GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}">
<Category>EventCollection</Category>
<DataSources>
<DataSource ID="_F6DA1507_12AF_11D3_AB21_00A0C98620CE_" Comment="{F6DA1507-12AF-11D3-AB21-00A0C98620CE}" TypeID="Windows!Microsoft.Windows.EventProvider">
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<LogName>Application</LogName>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/ServiceName$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>6624</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="GenerateAlert" TypeID="SystemHealth!System.Health.GenerateAlert">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.SQLServer.2014.XML___XML_document_could_not_be_created_because_server_memory_is_low._Use_sp_xml_removedocument_to_release_XML_documents_1_5_Rule.AlertMessage"]$</AlertMessageId>
<AlertParameters>
<AlertParameter1>Event ID: $Data/EventDisplayNumber$. $Data/EventDescription$</AlertParameter1>
</AlertParameters>
<Suppression>
<SuppressionValue/>
</Suppression>
</WriteAction>
</WriteActions>
</Rule>