Recently in the performance test to find bingmap memory leaks (memories leak) problems, find some foreign posts, found that there are similar problems, but there is no good solution.
https://social.msdn.microsoft.com/Forums/en-US/3226f255-2ae1-4718-b848-5f24e76b64b0/ Your-pushpins-are-broken-addremove-leads-to-memory-leak?forum=bingmapsajax
After some attempts, a compromise solution was found to share.
Let's stick to testing code:
<! DOCTYPE html><%--<meta http-equiv= ' x-ua-compatible ' content= ' ie=7;ie=9 '/>--%>Analyze the specific reason, that is, to add Pushpin to the map, actually added an HTML element, but when the removal is only called _layre.remove (pushpin) or _layer.removeat (index), These two methods are the same effect, except that the Pushpin object is removed from the Bingmap entitycollection collection, but the Pushpin HTML object still exists in memory, so increasing the removal frequently causes memory to grow.
Test results:
1. The cfsnew HTML elements are placed directly on the page, and then each time the DOM element is taken to add to the map, the memory growth rate is approximately 10M per second.
2. The cfsnew HTML is assigned to Pushpin's contenthtml in the form of a var string, and the memory growth rate is approximately 1M per second.
3. If you do not use HTML format pushpin, with the default pushpin icon (Teardrop-shaped), memory increases the frequency of 0.1M per second.
4. Added $ (' #cfsNew '). Remove (); After the method, the memory continues to increase and the situation disappears.
At the moment I'm just going to fix this by removing the HTML object manually, but because the HTML for each icon is different, you also need to bind special attributes to make such a tag, adding a lot of inconvenience to the development of the program, or hoping that Microsoft will find and solve the problem.
Bingmap frequent add pushpin and delete pushpin can cause memory leaks