managed code

Time:2020-4-4

What is managed code? Learning process.

 

managed code

C is one of the managed code. The execution of managed code can be managed by the runtime, which is called the common language runtime (CLR) in. Net.

Managed code is first compiled into intermediate language (IL) by compiler, then CLR starts just in time (JIT) to compile IL into machine code, and provides automatic memory management, security boundary, type security and other services.

CLR allows the managed code to cross the boundary, and C language allows you to use the so-calledUnsafe context(specifies snippets of code whose execution is not managed by the CLR), using unmanaged constructs, such as pointers, directly in the code.

 

Automatic memory management

CLR has a garbage collector that automatically allocates and frees memory.

CLR creates a “continuous address space” for the application process, i.e. “managed heap”. When an application creates an object of reference type, the garbage collector will fetch the address space on the managed heap in order. If the address space is available, memory will be allocated for the newly created object in the address space. Otherwise, it will skip to the next address space.

The garbage collector maintains the “object activity root” list by accessing the runtime, knows which objects do not have access access to, and then releases the memory occupied by these objects.

When a large number of inaccessible objects are recycled, the method of compressing memory is adopted. However, to avoid moving large objects in memory, this memory is not compressed.

 

To be read https://docs.microsoft.com/zh-cn/dotnet/standard/automatic-memory-management

 

Recommended Today

Python basics Chinese series tutorial · translation completed

Original: Python basics Python tutorial Protocol: CC by-nc-sa 4.0 Welcome anyone to participate and improve: a person can go very fast, but a group of people can go further. Online reading Apache CN learning resources catalog introduce Seven reasons to learn Python Why Python is great Learn Python introduction Executing Python scripts variable character string […]