.NET Components for Mobility

Memory leak mobile in the hand 3.2

Last post 07-24-2008 12:53 PM by PeterFoot. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-23-2008 8:27 AM

    • MGOO
    • Top 500 Contributor
    • Joined on 07-23-2008
    • Posts 2

    Memory leak mobile in the hand 3.2

    Hello,

     

    I am developping an application in vb.net, using Mob 3.2, and i have noticed a memory leak.

    I have to open and close an outlook session and an email account every five seconds,  and have to do this all day long.

    But it seems that disposing the _EmailAccount doesn’t work.

    After 300 attemps, the memory is 1 Mb lesser.

      

    Here is the sample code (after doing this 300 times,  we can easily see a memory leak) :

     Private _Session As OutlookSession            Private _EmailAccount As InTheHand.WindowsMobile.PocketOutlook.EmailAccount 

                                    Private Sub test()               

    _Session = New OutlookSession            _EmailAccount = _Session.EmailAccounts(0)            If Not _EmailAccount Is Nothing Then                _EmailAccount.Dispose()                _EmailAccount = Nothing 

               End If

    If Not _Session Is Nothing Then                _Session.Dispose()               _Session = Nothing     

           End If

    End Sub  Am i doing a wrong things ?

    Thanks

  • 07-24-2008 12:53 PM In reply to

    Re: Memory leak mobile in the hand 3.2

    You can massively optimise this code by creating a single instance of the OutlookSession for the lifetime of your application, likewise cache the _EmailAccount outside of this loop so you don't need to reconstruct it each time. You may also be able to replace your code and use the MessagingItem* events exposed by OutlookSession in 3.2 which fire when changes occur.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
Page 1 of 1 (2 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.