none
Possible memory issue with add-in RRS feed

  • Question

  • I have created an add-in for Outlook that looks for patterns in the header and footer of each email. The add-in works fine except after 50 straight emails or so it stops working correctly. When I close Outlook, open it and run the add-ins again, no problem until I run another set of 50 or so of emails. Question, is this an issue with memory? At the start of the add-in a method is called to get all registry settings. That called is at the beginning and never called again while the add-in and Outlook is open. 
    Tuesday, December 6, 2016 3:39 PM

Answers

  • Hello,

    Do you release underlying COM objects in a timely manner?

    Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. Read more about that in the Systematically Releasing Objects article.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by bthumber Wednesday, December 7, 2016 6:30 PM
    Tuesday, December 6, 2016 4:08 PM

All replies

  • Please show the relevant snippets of your code. What does "stops working correctly" mean? Do you get an error?

    Does calling GC.Collect() at the end of each cycle help?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, December 6, 2016 3:48 PM
  • Hello,

    Do you release underlying COM objects in a timely manner?

    Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. This is particularly important if your add-in attempts to enumerate more than 256 Outlook items in a collection that is stored on a Microsoft Exchange Server. If you do not release these objects in a timely manner, you can reach the limit imposed by Exchange on the maximum number of items opened at any one time. Read more about that in the Systematically Releasing Objects article.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by bthumber Wednesday, December 7, 2016 6:30 PM
    Tuesday, December 6, 2016 4:08 PM