C # Memory allocation learning

Source: Internet
Author: User

The CLR memory allocation is divided into three chunks: Stack, GC heap, and large object heap.

One, thread stack (stack)

Used to assign a value type instance. The stack is managed by the operating system and is not managed by the GC, and its occupied stack space is automatically freed when the value type is not in its scope (primarily the function in which it resides). The execution efficiency of the stack is very high.

Second, GC heap (heap)

Used to allocate small object instances. The so-called small object is an instance object of size less than 85000 bytes. GC Heap is managed by three generations of garbage, and when GC operations (garbage collection) are performed, the garbage collector compresses the GC heap. The specific GC operation (slightly).

Three, large Object heap (LOH)

Used to allocate large object instances. A large object is an instance object that is less than 85000 bytes in size. Large objects are allocated on the Loh, are not controlled by GC, are not compressed, and are recycled only when fully GC is reclaimed.

Attention

A. The allocation of stacks is to the low address extension, and the heap allocation is to the high address extension.

B. The value parameter is the essence of the reference parameter, and the value parameter is a copy of the data in the stack, and the reference parameter is a reference to the stack address. When the value parameter is a reference object, you can change some values of the Reference object, but you cannot change the value to the address of the new object.

C. Objects in the heap have Synchronous block index (4 bytes), type handle (4 bytes)

D. Static fields, static methods, and methods that are assigned to and-----method tables

C # Memory allocation learning

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.