MSSQL 2016: XML : XML document could not be created because server memory is low. Use sp_xml_removedocument to release XML documents

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

When you execute sp_xml_preparedocument , a parsed XML document is stored in the internal cache of SQL Server 2000. The MSXML parser uses up to one-eighth the total memory available for SQL Server. There is not enough memory in the portion of cache allocated to MSXML to open the document specified in the sp_xml_preparedocument statement. This may be because the specified document is very large or because documents already in that memory space do not leave enough space for the new document.

Knowledge Base article:

Summary

When you execute sp_xml_preparedocument , a parsed XML document is stored in the internal cache of SQL Server 2000. The MSXML parser uses up to one-eighth the total memory available for SQL Server. There is not enough memory in the portion of cache allocated to MSXML to open the document specified in the sp_xml_preparedocument statement. This may be because the specified document is very large or because documents already in that memory space do not leave enough space for the new document.

For more information about parsing XML documents, see "sp_xml_preparedocument" and "sp_xml_removedocument" in Books Online.

Resolutions

Execute sp_xml_removedocument to remove documents from memory. Verify that your code always calls sp_xml_removedocument when you have finished processing a document. Your code should account for the possibility that a connection or transaction is interrupted between the sp_xml_preparedocument and the sp_xml_removedocument calls. To accomplish this, you may need to store open document handles in a table where you can reference them if a batch is interrupted.

Overrideable Parameters

Name

Description

Default Value

Enabled

Enables or disables the workflow.

Yes

Priority

Defines Alert Priority.

1

Severity

Defines Alert Severity.

1

Element properties:

TargetMicrosoft.SQLServer.2016.DBEngine
CategoryEventCollection
EnabledTrue
Event_ID6624
Event Source$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/ServiceName$
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
RemotableTrue
Alert Message
MSSQL 2016: XML : XML document could not be created because server memory is low. Use sp_xml_removedocument to release XML documents
{0}
Event LogApplication
CommentMom2016ID='{136A2E5E-A460-4FAE-8587-D72C945E89EB}';MOM2016GroupID={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.2016.XML___XML_document_could_not_be_created_because_server_memory_is_low._Use_sp_xml_removedocument_to_release_XML_documents_1_5_Rule" Target="SQL2016Core!Microsoft.SQLServer.2016.DBEngine" Enabled="true" ConfirmDelivery="true" Remotable="true" Comment="Mom2016ID='{136A2E5E-A460-4FAE-8587-D72C945E89EB}';MOM2016GroupID={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="SQL2016Core!Microsoft.SQLServer.2016.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.2016.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>