[Record] What the new operator does

Source: Internet
Author: User

1. The number of bytes required for all instance fields defined in the calculation type and all base types (until system. Object, although it does not define its own instance fields. Each object on the stack needs some additional members-"type Object Pointer" and "synchronous block Index ". These members are used by CLR to manage objects. The number of bytes of these additional members is the size of the incoming object.

2. It allocates bytes of the specified type from the managed heap to allocate the object memory. All allocated bytes are set to 0.

3. It initializes the "type Object Pointer" and "synchronization block Index" members of the object.

4. The strength constructor of the call type to pass in any real parameters specified in the call to new. Most compilers automatically generate code in the constructor to call a base class constructor. Each type of structure is responsible for initializing the instance fields defined by this type during the call. Finally, the system. object constructor is called. The constructor simply returns the constructor knowledge and does not do anything else. To prove this, you can use ildasm.exe to load mscorlib. dll and check the system. object constructor.

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.