Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to handle 5.2 Performance and Resource Management issue on WP7

DZone's Guide to

How to handle 5.2 Performance and Resource Management issue on WP7

· Mobile Zone
Free Resource

Get gorgeous, multi-touch charts for your iOS application with just a few lines of code.

Recently, I came across the 5.2 Performance and Resource Management issue. This is a problem because you do not really get a whole lot of direction as to what is wrong with your application. So here are some basic tips to troubleshoot this issue very quickly.

1) Check your tombstoning and make sure it is quick and you are not saving large data back and forth into the isolated storage

2) MAKE SURE you dispose of everything, especially any type of streams. This was in fact one of the issues with one of my apps. Below is the sample code that fixed my app issue.

Problem Code:

public void PlaySound(string sound)

{

  using (Stream stream = TitleContainer.OpenStream(sound))

  {

    AnimalSoundEffect = SoundEffect.FromStream(stream);

    FrameworkDispatcher.Update();

    AnimalSoundEffect.Play();

  }

}

 

Fix Code:

public void PlaySound(string sound)

{

    Stream stream = null;

    try

    {

        stream = TitleContainer.OpenStream(sound);

        AnimalSoundEffect = SoundEffect.FromStream(stream);

        FrameworkDispatcher.Update();

        AnimalSoundEffect.Play();

    }

    catch (Exception ex)

    {

        LogDto logDto = new LogDto();

        logDto.Message = ex.Message;

        logDto.Title = “Sound Failure”;

        ToeTapzServiceViewModel.Instance.LogException

            (Settings.Instance.CurrentTrackingAppId, “Pull And Speak” , logDto);

    }

    finally

    {

        // Make sure to Dispose this stream or the garbage collector

        // takes FOREVER to kill it and the app loads REALLY slow on the next launch

        if (stream != null)

        {

            stream.Dispose();

        }

    }

}

Notice the problem code above. I do in fact get rid of my stream using “Using” but that did not work for me so I had to resort to good old fasion style using to finally dispose of it. There must be a delay in how “Using” disposes of resources vs. actually calling the Dispose method directly.

.Net developers: use Highcharts, the industry's leading interactive charting library, without writing a single line of JavaScript.

Topics:

Published at DZone with permission of Henry Lee, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}