none
Memory bloat when using Bing Maps Windows 8 SDK control under single-page navigation model? RRS feed

  • Question

  • My app uses the single-page navigation model (the built-in Navigation App JavaScript template in VS2012). One of the app's page controls uses the Bing Maps Windows 8 JS SDK to display a simple map. The map works like a champ, but repeated navigations to/from this page control make the app hog memory. For example, letting the app run overnight leads to memory usage in the ballpark of half a gig (!).

    I was able to reproduce this problem using a blank app built from the Navigation App template and a very basic use of the Bing Maps control (I followed the "Getting Started" instructions here). I set timers to navigate back and forth between the maps page and another blank page control automatically, a few times per minute.

    Sure enough, memory usage topped 200MB within a few hours and shows no sign of plateauing.

    Has anyone else encountered this problem? Are there things I need to do to plug this memory leak? I've tried calling map.dispose() on the page control's unload event, with no apparent effect. Not sure what else to try...

    Thanks very much!


    Wednesday, April 24, 2013 4:32 PM

Answers

  • As you move the map it loads in more data. This uses more memory. This is to be expected and has been addressed in a number of other posts in this forum. the only way around this would be to host all the data in the app, but Bing Maps consists of over 9 petabytes of data so you will have a hard time finding a tablet with that much storage (and offline storage is also against the terms of use)

    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Thursday, April 25, 2013 5:48 PM
    • Unproposed as answer by Matt Hauger Tuesday, April 30, 2013 12:08 PM
    • Marked as answer by Ricky_Brundritt Thursday, May 16, 2013 7:35 AM
    Thursday, April 25, 2013 5:48 PM
  • Just a follow-up here: I did find a workaround that prevents the memory bloat, although it wouldn’t be ideal for all apps. Thought I’d share it in case others run into the same issue.

    In short, we call window.location.reload() periodically. This seems to release everything (including the map stuff) from memory. It’s a bit overkill, and it demands some costly refresh time (and probably some extra billable API calls). But for an app as lightweight and small-scale as ours, it may do the trick in the short-term.

    • Marked as answer by Matt Hauger Monday, May 13, 2013 8:03 PM
    • Unmarked as answer by Matt Hauger Monday, May 13, 2013 8:03 PM
    • Marked as answer by Ricky_Brundritt Thursday, May 16, 2013 7:35 AM
    Monday, May 13, 2013 8:03 PM

All replies

  • As you move the map it loads in more data. This uses more memory. This is to be expected and has been addressed in a number of other posts in this forum. the only way around this would be to host all the data in the app, but Bing Maps consists of over 9 petabytes of data so you will have a hard time finding a tablet with that much storage (and offline storage is also against the terms of use)

    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Thursday, April 25, 2013 5:48 PM
    • Unproposed as answer by Matt Hauger Tuesday, April 30, 2013 12:08 PM
    • Marked as answer by Ricky_Brundritt Thursday, May 16, 2013 7:35 AM
    Thursday, April 25, 2013 5:48 PM
  • Thanks for the reply, Richard. Hmm... this is tricky. I'm not quite sure how to proceed; as its memory footprint grows, the app becomes less and less responsive. Eventually, it hangs and gets terminated by Windows. Granted, this happens after several hours/days of run time, but the app is geared for exactly this sort of set-it-and-forget-it use case.

    It sounds like you're saying it's not possible to force-release the memory used by the map control---even when the map is off-screen?

    Thursday, April 25, 2013 6:14 PM
  • FWIW: the app automatically shows the same map view and makes the same Search API requests every time it navigates to the map page control. But despite calling for the same data, the memory usage continues to climb. Seems strange.

    Also, I've read here on the forums that memory use will "cap" at a certain point. What is the cap? Is there any way to set this value programmatically?

    Tuesday, April 30, 2013 6:32 PM
  • Just a follow-up here: I did find a workaround that prevents the memory bloat, although it wouldn’t be ideal for all apps. Thought I’d share it in case others run into the same issue.

    In short, we call window.location.reload() periodically. This seems to release everything (including the map stuff) from memory. It’s a bit overkill, and it demands some costly refresh time (and probably some extra billable API calls). But for an app as lightweight and small-scale as ours, it may do the trick in the short-term.

    • Marked as answer by Matt Hauger Monday, May 13, 2013 8:03 PM
    • Unmarked as answer by Matt Hauger Monday, May 13, 2013 8:03 PM
    • Marked as answer by Ricky_Brundritt Thursday, May 16, 2013 7:35 AM
    Monday, May 13, 2013 8:03 PM