[Silverlight entry series] Silverlight Memory leakage Tool

Source: Internet
Author: User

WriteProgramFrom C ++ Memory leakage, JavaScript Memory leakage, iPhone Memory leakage,. net Memory leakage and Silverlight Memory leakage. As long as it is a program, you must pay attention to the memory leakage issue. Otherwise, there will be endless troubles. In managed platforms such as. NET and Java, although GC is working, if the unmanaged resources are not manually released, the GC delay will cause your memory to soar and cause you a headache. We recommend two siverlight and. Net Memory leakage monitoring and performance monitoring profiler/loading profiling tools:

1. Ants memory profiler (Redgate). Click the download link. Click this link for detailed usage. Memory monitoring method.

2. dottrace4, leading profiling tool for. NET applications. Click this link for detailed usage. There is also a monitoring Case demonstration, which is very detailed.

Using these two tools can effectively help us monitor Silverlight Memory leakage.

 

How to determine whether an object has been released without memory leakage using the ants memory profiler (Redgate) tool to run the program, open a form, take a snapshot, and disable the form, take another snapshot and compare the two snapshots to see if the form is released?
If it is not released, check who references it and the GC does not release it. The strength of ants memory profiler is that you can clearly see that this object is being referenced by other objects. Redgate recommends that you pay close attention to whether unreleased objects are referenced by events of Type eventhandler <t>. This is a common memory leak. The solution to the form close example above is also very simple, that is, adding eventhandler-=... in the form close event to release the event listening. The essence of eventhandler is delegate, which makes the event listener a reference to eventhandler + =... in this sentence, the two objects are linked, and the event listener is used as a reference. That is to say, an object is strongly referenced by another object and cannot be released by GC. Another method to solve this memory leakage is the weak reference- Weakreference But relatively strong references may cause some performance loss.

 

GC object collection mechanism

 

Whether an object will be recycled depends on whether the reference can be accessed during reference traversal by the garbage collector. If the reference cannot be accessed, it will be recycled. If the reference can be accessed, it cannot be recycled. That is to say, before GC collection, GC determines that the object has no reference. GC's mechanism for identifying "useless" objects is to determine whether the objects are referenced by "root. Here, "root" is a general term for a group of objects currently in use or may be used in the future. It generally includes the following objects: type Static fields, current method parameters, local variables, CPU registers, etc.

 

 

Do not perform Memory Leak Monitoring after the project is developed!

If your project is finished,CodeIt is too late to perform memory monitoring after the development is complete. If the memory leakage problem is found at this time, the cost of taking action is relatively high. We recommend that you monitor the memory when a sprint is completed, a small module, or a baseline is completed, and the system can run properly. At this time, you can discover system problems, it is not costly to promptly fix problems.

Silverlight Memory leakage Article Reference

Article 1 (recommended !), Article 2, Article 3, Article 4 (recommended), article 5, finding memory leaks in WPF-based applications (strongly recommended)

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.