none
[UWP] Map control memory leaks and continious network calls

    Question

  • Hi,

    I'm currently working on a banking app. One page use a mapcontrol. With fiddler my client noticed that the control was sending http request (even if the map has been already download). 

    It's ok with them but the problem is that when I navigate to an other page the request keep coming (1 per second !).

    A background agent or something alike must be started by the map control. 

    Is there a way to close/destroy/free the memory of the map control that I could call on my OnNavigatedFrom event ? 

    I tried to set the control to null and to call the garbagecollector without success and did not found any information about this so far... 

    ex of request send by the map control
    Host: t0.ssl.ak.tiles.virtualearth.net:443

    Host: t0.ssl.ak.dynamic.tiles.virtualearth.net:443

    Regards,

    Thierry


    • Edited by Thierry.T Wednesday, December 30, 2015 9:56 AM other issues found
    Thursday, December 17, 2015 4:58 PM

Answers

  • I was testing on a 10240 system. On a 10586 system I can see the resize memory issue.

    I'll report to the appropriate team both the memory leaks.

    Thursday, January 7, 2016 5:59 PM
    Moderator
  • I'll keep looking, but I can't reproduce issue 1 or 3 with this project. I see no additional network requests after the control loads and displays data. I'm not sure why you would be seeing something different. There are some requests the control makes that it will retry if they fail. I can't see from your screenshot if the requests you're seeing are failures or not.

    For issue 3, I see some small memory variation depending on the windows size, but no consistent growth over time.

    For issue 2, I am seeing memory growth with each page load. A pretty simple workaround is just to construct a single map control instance as a static and add it to the page in code behind rather than constructing a new one with each page. You'll get better load perf that way as well.

    Thursday, January 7, 2016 1:07 AM
    Moderator
  • Hi Duncan thank for digging into this. 

    Ok for your issue workaround (manualy clearing the map work also) but it would be nice if it could be fixed in futur released :) 

    I tried my solution on coworker computers :

    -on a coworker laptop with windows 10 10240 the memory leak on resize and network calls was not present (same behavior as you).

    -on a coworker laptop with an up to date windows 10 (10586)  the memory leak on resize was present but not the network calls...

    Do you have an up to date Windows 10 ? 

    I tried modifiying the target version of the project but it didn't change anything on my computer... 

    Thursday, January 7, 2016 10:39 AM
  • Yep, we run all kinds of versions for testing.

    One of the devs looking at the bug noticed that issue #2 is because your sample is leaving each page on the back stack. This keeps a reference to the XAML page and thus the map control instance, which is why the memory was growing. If you clear the back stack, there's no memory growth.

    Memory issue on resize should be fixed in a future update.

    Tuesday, January 12, 2016 8:42 PM
    Moderator

All replies

  • Which map control are you using? For UWP apps, you should use the built-in map control with Win10. That control generally shouldn't be making requests to for raster tiles, unless you're in aerial mode. Even then, requests should stop once the scene is resolved.
    Friday, December 18, 2015 5:20 PM
    Moderator
  • Hi Duncan, 

    I'm using the built-in map control ( xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps" [...] <Maps:MapControl />

    with default configuration.

    You can easily reproduce by creating a new app with 2 page (one with the map the other empty). Once you navigate to your page with the mapcontrol the request start every two seconds, even if you navigate on the blank page.

    I will add that the map control has serious memory leak issue

    • each time I navigate to my page with the map the memory consuption of my app increase by 16 Mo
    • each time I resize the map p the memory consuption of my app increase  by 10Mo

     For the first point manualy clear the map and call the garbagecollector fix the leak. 

    Regards,

    Wednesday, December 30, 2015 9:54 AM
  • I'm not able to reproduce either of the issues you describe. Simple app with two pages - start page with a navigate button which navigates to a page with a map control. On navigation to the map control page, I see a few network requests for map data which stop pretty much immediately. I see a ton of network requests for VS analytics, but that's unrelated to the map control.

    Resizing the control doesn't appear to change the memory usage (this is with the map control set to stretch to fill the whole page).

    Perhaps there's more to the scenario like adding map icons or attaching events? A common cause of leaks is failing to detach events properly on page destruction.

    Tuesday, January 5, 2016 5:33 PM
    Moderator
  • Hi Duncan,

    It's pretty strange your project should reproduce the issues I have. I know other developpers with the same problems as me. 

    Here is the link to my reproduction project (should be the same as you) : 

    http://1drv.ms/1OzA2Oa

    And the steps and screenshot that show the issues :

    1st issue : constant http requests : navigate to the map page, navigate to the main page, request keep comming1st navigation to map page

    navigate to main page request keep poping on fiddler

    2nd issue : map memory is not released on navigated from : navigate again on map page

    memory footprint increase

    3rd issue memory leak on resize : resize your page containing the map

    memory footprint increase at eache resize

    Can you reproduce ? 

    Regards,

    Wednesday, January 6, 2016 10:03 AM
  • I'll keep looking, but I can't reproduce issue 1 or 3 with this project. I see no additional network requests after the control loads and displays data. I'm not sure why you would be seeing something different. There are some requests the control makes that it will retry if they fail. I can't see from your screenshot if the requests you're seeing are failures or not.

    For issue 3, I see some small memory variation depending on the windows size, but no consistent growth over time.

    For issue 2, I am seeing memory growth with each page load. A pretty simple workaround is just to construct a single map control instance as a static and add it to the page in code behind rather than constructing a new one with each page. You'll get better load perf that way as well.

    Thursday, January 7, 2016 1:07 AM
    Moderator
  • Hi Duncan thank for digging into this. 

    Ok for your issue workaround (manualy clearing the map work also) but it would be nice if it could be fixed in futur released :) 

    I tried my solution on coworker computers :

    -on a coworker laptop with windows 10 10240 the memory leak on resize and network calls was not present (same behavior as you).

    -on a coworker laptop with an up to date windows 10 (10586)  the memory leak on resize was present but not the network calls...

    Do you have an up to date Windows 10 ? 

    I tried modifiying the target version of the project but it didn't change anything on my computer... 

    Thursday, January 7, 2016 10:39 AM
  • I was testing on a 10240 system. On a 10586 system I can see the resize memory issue.

    I'll report to the appropriate team both the memory leaks.

    Thursday, January 7, 2016 5:59 PM
    Moderator
  • Glad we finaly found out a way to reproduce ! (Ms employee are not working on up to date computers ? :) )

    Do you also have the continuous network calls ?

    Friday, January 8, 2016 9:23 AM
  • No, I don't see any additional network calls on any system.

    The Road mode shouldn't be hitting any virtualearth.net endpoints ever. Those would only occur in aerial mode.

    Friday, January 8, 2016 10:16 PM
    Moderator
  • I also experience heavy memory problems with map Control:

    [UWP] [MapControl] Memory Issue/Bug

    Exists on both win10 builds 10240 and 10586  ...  ?

    MapCtrl (Aerial3D view) allocates memory and allocates memory and allocates memory and allocates memory and NEVER EVER frees it.

    Monday, January 11, 2016 11:38 AM
  • Just a quick response in regards to "Ms employee are not working on up to date computers ?". The team usually works on different versions. Duncan is running the version that is most installed by users, which is were issues are most likely to be reported. While I on the other hand am running the latest internal builds of Windows which aren't even available through the public insider program.

    http://rbrundritt.wordpress.com

    Monday, January 11, 2016 5:50 PM
  • Yep, we run all kinds of versions for testing.

    One of the devs looking at the bug noticed that issue #2 is because your sample is leaving each page on the back stack. This keeps a reference to the XAML page and thus the map control instance, which is why the memory was growing. If you clear the back stack, there's no memory growth.

    Memory issue on resize should be fixed in a future update.

    Tuesday, January 12, 2016 8:42 PM
    Moderator
  • Ok, didn't thought about that with the new Windows auto-update process on computers. 

    I'm looking forward to the next sdk release with your fixes :) 

    Thierry,

    Wednesday, January 13, 2016 1:23 PM