locked
Outlook 2007 Memory Leak RRS feed

  • Question

  • I have a memory leak problem accessing ItemProperty values of Outlook 2007 items in VB 2008. When I comment out the ItemProperty section of my code the memory is released as expected so I know the problem is with that section.

    What I want to do it to synchronize Outook items with an Access Database by looping in the Outlook ItemProperty collection of Outlook items, I am trying to skip over COM objects of course to only sync intrinsic type properties.

    I tried first to check the type by calling Marshal.IsComObject(ItemProperty.Value) but it look like that call is enought to allocate the COM object so I then tried to explicitly allocate the COM object to ba able to release it after but to no avail.

    Here is the code section with the explict allocation:

            For PropertyIndex = 0 To ItemProperties.Count - 1
                ItemProperty = ItemProperties(PropertyIndex)
                Value = ItemProperty.Value
                If Marshal.IsComObject(Value) Then
                    Marshal.ReleaseComObject(Value)
                    Value = Nothing
                    GC.Collect()
                    GC.WaitForPendingFinalizers()
                    GC.Collect()
                Else
                    'Call SyncValue()
                End If
                Marshal.ReleaseComObject(ItemProperty)
                ItemProperty = Nothing
                GC.Collect()
                GC.WaitForPendingFinalizers()
                GC.Collect()
            Next PropertyIndex

    Thanks!

    Saturday, December 25, 2010 2:30 AM

All replies

  • Hello VAlain,

    Thanks for posting. To reproduce this issue on my side, would you mind simplifying a project and sharing it with me? Once it is reproduced, I could do some research on it. Also you could try to search it in VSTO forum or Outlook forum, and you might get some resources about it. Have a nice day.

    If you have any concern on this post, or the resources do not help you, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 27, 2010 9:31 AM
  • Here is a simplified project reproducing the problem:
    http://cid-ffdee0950ad69e90.office.live.com/self.aspx/Public/Projects/OlTest.zip

    When I Click "Compare Items", if "Check Values" is checked the memory usage of Outlook will grow without been unallocated, if it is not checked the memory is released as expected.

    To try it just select a folder containing items in Outlook before clicking the button.

    Have a nice day!

    Monday, December 27, 2010 7:09 PM
  • Hello VAlain,

    Sorry for delay. I will try to use this sample on my side. If I have any useful point shared with you, I will follow up again. Thanks again.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 29, 2010 10:26 AM