Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory resources not being released in Windows Phone 8
    primarykey
    data
    text
    <p>I'm working on a Windows Phone 8 app and I'm having an issue with releasing resources from a file stream. The problem happens when I access the isolated storage to get an image, and then I set the image to an image source on the view; this all happens when the page loads. (I'm using the Windows Phone Application Analysis tool to view the memory usage). Also, whenever I close and reopen the page in the app, the memory usage continues to increase.</p> <p>This is my code to get the image and set it:</p> <pre><code>IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("background.jpg", FileMode.Open, FileAccess.Read)) { BitmapImage imageFile = new BitmapImage(); imageFile.SetSource(fileStream); BackgroundImage.ImageSource = imageFile; // tried using .Close() but it wasn't releasing the resources as well. fileStream.Dispose(); } </code></pre> <p>Is there something else I should be doing to properly release the resources?</p> <p><strong>EDIT</strong></p> <p>I realized my problem... When the app first starts I have it setting the same image that I'm opening in the code above. So when I open a new page with the same image, it seems to not be releasing the existing file stream resources because it's opening the same file over and over again. The fix was to add a BitMapImage property in my View Model that I can access whenever I need without having to constantly grab the file in the isolated storage.</p> <p>Thanks for all the help from everyone</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload