Avoid performance problems caused by MCMS Publishing API

Avoid performance problems caused by MCMS Publishing API

Inproper use of the MCMS publishing API can cause significant performance problems in MCMS. A good summary of things to avoid and to do is listed in Chesters article.

Beside the hints in Chesters article here are some less good known facts you need to be aware of:

1) Do not use the HtmlPlaceholder.Text property

The implementation of the Text property of the HtmlPlaceholder object can cause serios performance problems due to the fact that the implementation of this property is done in a STA threaded COM object. This can cause serialization problems as only one page request can use this property at a given time. Other requests using the same property will be queued up which can cause serious performance degrades.

Rather than using the Text property implement the following method in a utility class and pass in the Html property of the HtmlPlaceholder object:

2) Do not access custom properties by name if you are unsure if a custom property with this name exists

The implemenation of the custom property collection can cause serious performance problems when items are accessed by name which do not exist. The reason is that an internal exception is raised when the custom property cannot be found and this internal exception causes a similar serialization problem as one listed above with the Text property.

Affected code would look like the following:

if (posting.CustomProperties["PropertyName"] != null) ....

This code tries to access the Custom Property with name PropertyName and tests if it exists. Before "null" is returned the Custom Property Collection internally raises an exception which will then caues the serialization problem.

To ensure good performance you need to implement the following method in a Utility class:

3) Do not access placeholder objects by name if you are unsure if a placeholder object with this name exists

This is actually the same issue as listed under #2 with the custom properties.

Affected code would look like the following:

if (posting.Placeholders["PlaceholderName"] != null) ....

This code tries to access the Placeholder object with name PlaceholderName and tests if it exists. Before "null" is returned the Placeholder Collection internally raises an exception which will then caues the serialization problem.

To ensure good performance you need to implement the following method in a Utility class:

Thanks, were encountering a minor memory leak in our environment, we did implement accessing properties without knowing if it exists, could this be a possible cause to a memory leak? Were still using SP1a for MCMS