In my last blog entry i described how i found a memory leak in a BizTalk component. This entry will describe what the problem was and how I fixed it.
The memory analysis pointed to a class library that was not releasing memory. Inside the class library there was a method , shown below, that was being used to add an email attachment to a message.
public static void AddMessagePart(XLANGMessage msg, object oPart, string sPartName)
XLANGPart part = msg[sPartName];
part.SetPartProperty(typeof(MIME.FileName), sPartName + “.xml”);
This method is called by reference from an orchestration. What is wrong with it?
The XLANGMessage and XLANGPart parameters do not adhere to the rules for managing memory correctly (see http://support.microsoft.com/kb/917841). The following lines must be added to the method to cleanup;
if (msg != null)
if (part != null)
Thanks to Greg Forsythe for pointing this problem out.