Diagnosing Glass Mapper issues in Sitecore


Introduction

Glass Mapper is a third-party module that is widely used by Sitecore partners in their solutions. Sitecore and Glass Mapper have not been tested together, so we cannot guarantee the stability of such a configuration.

This article provides some examples of issues that might occur during such integration, and you can take some diagnostics steps in order to clarify if an issue is related to Glass Mapper.

Potential Issues And Diagnostics

There are the following potential issues:

 

High memory utilization

Symptoms

The issue can be caused by incorrect Glass Mapper API usage. In order to diagnose the behavior, comment out the usage of the Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.LoadAllValues() method in custom code or Glass Mapper sources used in a Sitecore-based project. Observe the memory usage levels and see if the issue persists.

Note: Removing the LoadAllValues method might cause problems when models are cached or lazy loading is disabled.

Solutions

 

High CPU utilization

Symptoms

The issue can be caused by a re-creation of item types when resolving the types using Glass Mapper. The problem can be noticed when calling Glass.Mapper.Sc.ISitecoreService.GetItem<T>(...).  Observe the CPU usage levels and see if the issue persists.

Note: The caching is not used by default.

Solution

To enable the type caching consider the guide from the following article: http://glass.lu/blog/2019-04-26-CacheAlwaysOn

 

Incorrect links or text

Symptoms

Text or links are wrongly encoded as well as rendering problems occur in the Experience Editor or front-end site on pages with Glass Mapper helpers.

Diagnostics

Replace Glass Mapper helpers with default Sitecore ones (for example, @Html().Sitecore().Field(…)), and see if the issue persists.

Solution

Ensure that you use the latest Glass Mapper version, use the default helpers, or contact Glass Mapper support.

General Recommendations And Useful Links