locked
Leak in Windows Runtime Component

    Question

  • Hi:

    I have written a Window Runtime component which works fine and I let it run over night. This morning my computer was out of memory. It is written in C#.

    Here is the whole code. I am unable to find where I have to look for memory leak.

    publicsealedclassFlipViewModel: INotifyPropertyChanged


        {

           

    privatereadonlyCoreDispatcher_dispatcher;

           

    publiceventPropertyChangedEventHandlerPropertyChanged;

           

    privateasyncTaskUiThreadAction(Actionact)

            {

               

    if(_dispatcher != null)

               

    await_dispatcher.RunAsync(CoreDispatcherPriority.Normal, act.Invoke);

            }

           

    privateasyncvoidPropertyChangedAsync(stringproperty)

            {

               

    if(PropertyChanged != null)

                   

    awaitUiThreadAction(() => PropertyChanged(this, newPropertyChangedEventArgs(property)));

            }

     

           

    privateint_showNumber = -1;

           

    publicintShowNumber

            {

               

    get


                {

                   

    return_showNumber;

                }

               

    set


                {

                    _showNumber =

    value;

                    PropertyChangedAsync(

    "ShowNumber");

                }

            }

           

    publicFlipViewModel()

            {

                _dispatcher =

    Window.Current.Dispatcher;

            }

    Best regards

    Agha Khan


    Agha Khan

    Tuesday, April 22, 2014 2:15 PM

All replies

  • Are you in an infinite loop with this code? 

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, April 22, 2014 7:38 PM
    Moderator
  • Dear Matt Small:

    It is a clock, so yes you are correct, I am in infinite loop.

    Best regards

    Agha Khan  


    Agha Khan

    Tuesday, April 22, 2014 7:45 PM