Bingmap frequent add pushpin and delete pushpin can cause memory leaks

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.