BingMap frequent Add Pushpin and Delete Pushpin may cause memory leakage, bingmappushpin

Source: Internet
Author: User

BingMap frequent Add Pushpin and Delete Pushpin may cause memory leakage, bingmappushpin

During a recent performance test, I found the memory leakage (memory leak) Problem in BingMap. I found some foreign posts and found 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, I found a compromise solution and shared it.

Paste the Testing Code first:

<!DOCTYPE html><%--<meta http-equiv='x-ua-compatible' content='IE=7;IE=9' />--%>

Analyze the specific cause, that is, when pushpin is added to the map, an HTML element is actually added, but the _ layre is called only when the map is removed. remove (pushpin) or _ layer. removeAt (index), the two methods have the same effect, but the Pushpin object is removed from the EntityCollection set of BingMap, but the html object of Pushpin still exists in the memory, therefore, frequent addition and removal may result in increasing memory.

Test results:

1. Place the HTML element of cfsNew on the page, and add it to the map every time by taking the DOM element. The memory growth rate is about 10 MB per second.

2. Write the cfsNew HTML into a var string and assign it to Pushpin contentHTML. The memory growth rate is about 1 MB per second.

3. If you do not need Pushpin in HTML format, use the default Pushpin icon (water drop). The memory increases by 0.1 MB per second.

4. After the $ ('# cfsNew'). remove (); method is added, the memory continues to increase.

At present, I only solve this problem by manually removing HTML objects by deleting them. However, because the HTML of each icon is different, we also need to bind special attributes for such a tag, it makes great inconvenience to program development, but Microsoft still hopes to discover and solve this problem.

 


 

 

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.