WinRT stream memory leak? RRS feed

  • Question

  • Can someone at Microsoft explain this?

    I've been working with some memory issues with my universal windows app.  It relates to the BackgroundTask part of the app which runs with limited memory in the windows phone environment so memory usage is quite important.

    I'm loading data from the local app store but the memory usage far exceeds the amount of data I am loading.  The high memory usage seems to come from stream objects and to demonstrate the point I have created a simple example:

    Create a new WPF app and place the following code in the Page's Loaded event:

    using (MemoryStream strm = new MemoryStream())

    Run the code and you will see figures like this in the output window:


    As you would expect the memory usage after the stream has been instantiated and then disposed is about the same as it was before anything happened.  This means that after I have used the stream object I can dispose it and rely on the memory returning to it's original level.

    Now create a windows universal app and try the same thing.  For the purpose of this test I did it in a windows app.

    The values in the debug window now read:


    This time the memory level is substantially higher after the stream has been disposed than it was before.

    Is there anyone out there who can explain this?

    Could it be a memory leak?

    Monday, June 8, 2015 5:27 PM

All replies

  • Are you writing Windows 10 Universal app or 8.1 app? Where did you place that code? I would suggest you using VS diagnostics tool to check GC point

    Best Regards,
    Please remember to mark the replies as answers if they help

    Tuesday, June 9, 2015 11:36 AM