Difference Between Stack and stack in C #

Source: Internet
Author: User

The storage sequence should be managed when stored in the stack, and the principle of going out is maintained. It is a continuous memory domain with automatic distribution and maintenance.

The heap is unordered. It is a non-sequential memory domain, and users can control and release it themselves. If the user does not release the memory, when the memory reaches a certain value, the garbage collector (GC) is used for garbage collection.

 

The reference type is always stored in the heap.

Value types and pointers are always placed in the declared places.

Call method: the system first places an encoding Code (the first address of the heap) on the stack and then places the parameters of the method. ThenCodeWhen the method is executed, find all the parameters for putting the heap header address in the stack and control the heap through the heap header address.

Reference Type: Always in the heap.

When we use a reference type, we are actually processing the pointer of this type. Instead of the reference type itself, the value type is used.

 

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.