OutOfMemoryException is thrown when getting Catalog Mappings


Description

All items in a catalog item branch might fail to load and cause an unhandled exception. The root cause of the issue is that the Catalog Mappings table has a considerable number of records and the size of catalog mappings exceeds 2 GB. The following message can be found in the logs:

ERROR Commerce.Connector - Request URL: GetCatalogMappings(environmentName='') - Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Text.StringBuilder.ToString()
   at Sitecore.Commerce.Engine.Connect.DataProvider.CommerceRepository.InvokeHttpClientGet(String serviceCallUrl, Boolean useCommerceOps, Boolean raiseException, String language, String environment, IDictionary`2 headers)
Exception: System.OutOfMemoryException
Message: Exception of type 'System.OutOfMemoryException' was thrown.
Source: mscorlib
   at System.Text.StringBuilder.ToString()
   at Sitecore.Commerce.Engine.Connect.DataProvider.CommerceRepository.InvokeHttpClientGet(String serviceCallUrl, Boolean useCommerceOps, Boolean raiseException, String language, String environment, IDictionary`2 headers)

Solution

To resolve the issue, consider one of the following options: