C # Memory Management

Source: Internet
Author: User

Windows uses a system: a virtual addressing system that maps the memory addresses available to the program to the actual addresses in hardware memory, which are managed entirely by Windows in the background. The actual result is that "each process on the bit processor can use 4GB of memory ˉ-no matter how much hard disk space is actually on the computer (on a 64-bit processor, this number is larger.) This 4GB of memory actually contains all parts of the program, including executable code, all DLLs loaded, and the contents of all variables used by the program when it runs. This 4GB of memory is called the virtual address space, or virtual memory.

Each storage unit in 4GB is sorted from 0 onwards. To access a value stored in a space in memory, you need to provide a number that represents that storage unit. In any complex high-level language, such as VB, C #, and Java, compilers are responsible for translating variable names that people can understand into memory addresses that the processor can understand.

In the virtual memory of the process, there is a region called the stack. The stack store is not a value data type for an object member. In addition, when a method is called, the stack is used to store copies of all parameters passed to the method.

Stack pointer (a variable maintained by the operating system represents the address of the next free storage unit in the stack.) The first time the program starts running, the stack pointer points to the end of the memory block reserved for the stack. The stack is actually filled down, which is populated from a high memory address to a low memory address. When the data is in the stack, the stack pointer is adjusted to always point to the next free storage unit. This scenario is shown in 13-1. In this diagram, the stack pointer 8o000 (16 binary OxC3500) is shown, and the next free storage unit is address 799999.

Note that, unlike stacks, the memory on the heap is allocated upward, so the free space is above the used space.

Organized from: C # Advanced Programming

Expand reading:

principles of. Net garbage Collection mechanism (i)
Principles of. Net garbage collection mechanism (ii )
. Net garbage collection and large object handling
. NET six key concepts: stacks, heaps, value types, reference types, boxing, and unpacking

Copyright: jiankunking Source: http://blog.csdn.net/jiankunking This article is copyright to the author and Csdn, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original connection.

C # Memory Management

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.