<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Wiz/dumb : CDOEXM</title><link>http://blogs.msdn.com/pcreehan/archive/tags/CDOEXM/default.aspx</link><description>Tags: CDOEXM</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>CDOEXM CreateMailbox is leaking memory</title><link>http://blogs.msdn.com/pcreehan/archive/2008/01/21/cdoexm-createmailbox-is-leaking-memory.aspx</link><pubDate>Mon, 21 Jan 2008 18:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7185460</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/7185460.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=7185460</wfw:commentRss><description>&lt;P&gt;I had a case recently where the customer had built an application to help manage their Active Directory environment. Part of this application used CDOEXM to create new mailboxes for their new user accounts. This is a common use of CDOEXM - nothing wrong so far. What this particular application was doing though was that when it had new work to do, it would spawn a new thread. On that new thread, they would CoInitialize, do their CDOEXM work, then CoUninitialize. The customer was reporting that the process leaked memory. Sure enough, commenting out the call to CreateMailbox prevented the leak.&lt;/P&gt;
&lt;P&gt;After debugging,&amp;nbsp;I discovered that some of the functions in the CreateMailbox code path use static variables. Each time CDOEXM is loaded and the execution hits those static variables for the first time, they'll be created in the static heap. Since his application spawned a new thread that did this for each user, the memory would increase by this amount each time. So the leak wasn't really a &lt;EM&gt;leak&lt;/EM&gt; as much as it was just the way static variables work and the way his application was structured simply &lt;EM&gt;used&lt;/EM&gt; an increasing amount of memory.&lt;/P&gt;
&lt;P&gt;By moving his loop inside the CoInitialize/CoUninitialize block, the memory usage remained static. &lt;/P&gt;
&lt;P&gt;So it seems that CDOEXM is not going to work well in an architecture like this. Here are some ideas for how to architect your solution to not run into this problem:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Spawn a new process to do your CDOEXM work (which will terminate when finished).&lt;/LI&gt;
&lt;LI&gt;Create a low (finite) number of background worker threads you can persist throughout the lifetime of your process that you can queue CDOEXM work to. This will allow you to call CoInitialize/CoUninitialize a controlled number of times.&lt;/LI&gt;
&lt;LI&gt;Put the CDOEXM code in a COM+ component and call it from your application. This way, your CDOEXM code just gets loaded in dllhost and you don't have to worry about it. Here's an &lt;A class="" href="http://blogs.msdn.com/mstehle/archive/2007/05/11/howto-using-cdoexm-in-asp-net-net-framework-2-0-walkthrough.aspx" target=_blank mce_href="http://blogs.msdn.com/mstehle/archive/2007/05/11/howto-using-cdoexm-in-asp-net-net-framework-2-0-walkthrough.aspx"&gt;article&lt;/A&gt; Matt wrote about how to do this in managed code.&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7185460" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDOEXM/default.aspx">CDOEXM</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Ooh, SNP</title><link>http://blogs.msdn.com/pcreehan/archive/2007/10/16/ooh-snp.aspx</link><pubDate>Tue, 16 Oct 2007 23:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5475221</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/5475221.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=5475221</wfw:commentRss><description>&lt;P&gt;We've recently been seeing an elevated number of cases where networking issues are adversely affecting performance and causing other problems with messaging technologies. The common thread in many of them is that the problem only started to occur after Windows Server 2003 SP2 was installed. I recently learned that we shipped a new feature in SP2 and turned it on by default. This new feature is called &lt;A href="http://www.microsoft.com/snp" mce_href="http://www.microsoft.com/snp"&gt;Scalable Networking Pack, or SNP&lt;/A&gt;. It was actually originally shipped as a &lt;A href="http://support.microsoft.com/kb/912222" mce_href="http://support.microsoft.com/kb/912222"&gt;download for SP1&lt;/A&gt;, but was included in SP2 by default. &lt;/P&gt;
&lt;P&gt;The Exchange team has posted an &lt;A href="http://msexchangeteam.com/archive/2007/07/18/446400.aspx" mce_href="http://msexchangeteam.com/archive/2007/07/18/446400.aspx"&gt;article&lt;/A&gt; on how SNP affects Exchange and also gives a good list of links and troubleshooting steps. &lt;/P&gt;
&lt;P&gt;SNP was built to increase performance on the networking stack, and does for newer network adapters that support it. However, for older network adapters, it can cause significant delays which cause timeout problems and connection problems leading to various problems. &lt;/P&gt;
&lt;P&gt;The basic troubleshooting steps at this point are &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Read the Exchange team's post linked above and pages they reference so you understand the issue &lt;/LI&gt;
&lt;LI&gt;Install the hotfix at &lt;A href="http://support.microsoft.com/kb/936594" mce_href="http://support.microsoft.com/kb/936594"&gt;http://support.microsoft.com/kb/936594&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;Upgrade your network adapter drivers to the most recent version &lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Disable the SNP features by setting the following registry keys: &lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableTCPChimney=dword:00000000 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableTCPA=dword:00000000 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableRSS=dword:00000000&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;I've just had another case where SNP was the culprit. The customer had clustered Exchange 2003 boxes with recently applied SP2. They were using backup software which was using CDOEXM to get information about the environment. These calls were failing with 0x8000FFFF (E_UNEXPECTED) but after debugging we saw that RPC was getting RPC_S_SERVER_UNAVAILABLE (1722 0x6ba) errors. This prompted me to ask about SNP. Disabling SNP via the steps above resolved the issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;STRONG&gt;UPDATE (1-8-07):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Yet again, another customer with clustered Exchange 2007 boxes. They had a MAPI application which was unable to OpenMsgStore on mailboxes that had migrated from Exchange 2003 (MAPI_E_FAILONEPROVIDER). Debugging the process I could see RPC_S_SERVER_UNAVAILABLE errors. Sure enough, they had SP2 installed. Disabling SNP resolved the issue. The reason nonmigrated mailboxes worked was that MAPI was just guessing the ServerDN since resolving against the DS didn't work. If the mailbox had never been migrated, this guess ended up being correct; for migrated mailboxes, it was wrong and the failure bubbled up.&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5475221" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDOEXM/default.aspx">CDOEXM</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item></channel></rss>