Use C # to display the visual effects of the garbage collection process

Source: Internet
Author: User
Tags garbage collection

No more nonsense, I am engaged in the web direction, C/S is not very familiar with, first look at the interface map (relatively rough), here is only a visual effect to initially show the GC corresponding operation (simple effect shows that is not true GC insider, that I do not understand)

Basic concepts

object's build process (newobj Directive)

1: Calculate the total number of bytes in all fields for type (including base class)

2: The total number of bytes plus the Object Cost field bytes (added as: The number of bytes required by the object). Each object contains 2 cost fields: The type object pointer and the synchronization block index. WIN32, each accounted for 32, WIN64, each accounted for 64 digits.

3:CLR detects if there is enough space in the managed heap to meet the number of bytes required by the object. If satisfied, the object is assigned to the location indicated by the Nextobjptr pointer, the instance constructor is invoked, and the new operation returns the memory address of the object. The pointer nextobjptr over the area where the object is located, indicating the address of the next new object in the managed heap. If not satisfied, do garbage collection.

Root

Each application has a set of root roots. A root is a storage address that contains a pointer to a type object.

The pointer has 2 forms: (1) pointing to an object in the managed heap. (2) set to NULL.

The root includes static fields, method parameters, local variables, and CPU registers.

Generation of objects

In the managed heap, the object's generation is about 0 generations, 1 generations, and 2 generations, and the corresponding memory capacity is 256k,2m,10m. Of course, the garbage collector automatically adjusts the budget capacity.

Related Article

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.