Geeks With Blogs

Tim Murphy

Tim is a Solutions Architect for PSC Group, LLC. He has been an IT consultant since 1999 specializing in Microsoft technologies. Along with running the Chicago Information Technology Architects Group and speaking on Microsoft and architecture topics he was also contributing author on "The Definitive Guide to the Microsoft Enterprise Library".

I review for the O'Reilly Blogger Review Program

Technorati Profile

Tim Murphy's .NET Software Architecture Blog Adventures in Architecting and Developing .NET

Memory leaks can cause strange and unexpected behaviors in your applications.  Of course in this day of managed code we don’t see it as often as we used to and many of us are getting rusty in our skill to eliminate these problems.

Recently I ended up with a misbehaving Outlook 2007 add-in which resulted in time spent with Microsoft support.  The first thing that came out of that was a way to detect if an Outlook 2007 is experiencing memory leaks.  Below is a command line command that seems to report back which email items were involved in memory leaks if any occur.

Outlook /reportleakedrenitems

So how do you handle the problem?  Since the unmanged code in this case are COM interop object  you use Marshal.ReleaseComObject from the the System.Runtime.InteropServices namespaces.  Any place where you are explicitly creating an object out of the from the Microsoft.Office.Interop.Outlook namespace you need to explicitly release it using this method.  If all goes well this will exercise the ghost from your system.

Here are a couple of links related to the topic for further reading.

• ReleaseComObject - How it works

• OOM.NET: Part 1 - Introduction and Why Events Stop Firing...

• OOM.NET: Part 2 - Outlook Item Leaks

Posted on Wednesday, October 26, 2011 9:38 AM Development | Back to top

Comments on this post: COM Interop Memory Leaks With Outlook 2007 VSTO Add-ins

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Tim Murphy | Powered by: | Join free