. NET garbage Collection

Source: Internet
Author: User

The garbage collector (GC) is used in the. NET for memory management, especially it can recover the memory that is needed by the running application.

. NET runtime is a garbage collector, which is a program that is designed to clean up memory. The method is that all dynamically requested memory is allocated to the heap (all languages are handled this way, but in the. NET, the CLR maintains its own managed heap for use by. NET applications). At intervals, when. NET detects that the managed heap for a given process is full and needs to be cleaned, the garbage collector is called. The garbage collector processes all variables in the current code, examines references to objects stored on the managed heap, and determines which objects can be accessed from code-that is, which objects have references. Objects that are not referenced are no longer considered to be accessible from the code and are therefore deleted.

An important aspect of garbage collection is its uncertainty. In other words, there is no guarantee when the garbage collector will be called: the CLR can call it when it decides it needs it. However, you can override this procedure to invoke the garbage collector in your code. This is helpful when testing, but should not be done in a normal program.

. NET garbage Collection

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.