Old Zhao Face questions reference answer (i)

Source: Internet
Author: User
Tags dot net garbage collection dot net framework

Recently, I just saw a blog post "I was interviewing." Net/c# programmers will ask questions, try to answer, and forget you add:

What is. NET. What is CLI. What is the CLR. What IL is. What the JIT is and how it works. What is GC, a brief description of how the GC works. what is. NET

Dot NET is a set of platforms that Microsoft presented in 2000, including the underlying operating system: Windows; Auxiliary products: dot NET Enterprise server; Mcirosoft XML Web service:. Net my services; Development platform: Dot NET Framework, Integrated development environment: Visual Studio. The above several parts are composed.

Underlying operating system: Of course, Windows provides XML Web service support for all operating systems. Starting with server operating system 2003, the personal operating system integrates the. Net Framework from Vista. and the operating system's original API is also beginning to be isolated with the DOT net API, its original idea is very large and radical, this is particularly evident in Vista development, and then Microsoft cut off some of the original ready to be released on the Vista features, but Vista has also shown that the predecessor is very different, Of course, the right and wrong twists and turns is another topic. In conclusion, Microsoft's focus on the dot net plan can be clearly seen in order for dot net to plan Microsoft's devotion to the operating system.

Auxiliary Products: We are more familiar with SQL Server it, but also a change of style, the first is that the integration of the original Enterprise Manager, Query Analyzer, tracker unification management tools

Microsoft XML Web services: They are all XML Web services provided by Microsoft, some of which are free of charge. (The XML Web service was really a "great subject" but later development was not as successful as Microsoft expected)

Development platform (dot NET Framework): Contains two parts of the common language runtime (CLR) and the DOT NET Framework class library (FCL). They provide a consistent programming model, simplified programming, reliable versioning (using the global assembly cache GAC to avoid DLL Hell), lightweight deployment management (the assembly comes with metadata that avoids the INI file and registry), Extensive platform support (as long as this machine is compatible with the CLR and FCL can be deployed, of course the Il becomes native code when it is run, seamless language integration (Java cross-platform, Dot net Cross-language, which is the argument that is often seen in the debate), Automated memory management (garbage collection), Type safety (the CLR prevents attacks with buffer overflow errors), the CLR supports Cross-language debugging, unified Error Reporting (all with exceptions and the original return error code), a new security Policy (CAS), compatible with previous COM components.

Integrated development environment: Visual Studio can be used to create Windows applications and network applications under the Windows platform, or to create network services, smart device applications, and Office plug-ins what is CLI.

The common Language Infrastructure (Common Language INFRASTRUCTURE,CLI) is a subset of the CLR, that is. NET, the part that ultimately manages the running environment of an application that is compiled into MSIL code. The CLI is in the lower half of the CLR structure diagram, mainly including the ClassLoader (class Loader), the Just-in-time compiler (IL to Native compilers), and the garbage collector (garbage Collector) of a run-time environment. The CLI is the soul of. NET and the CLR, and the CLI provides an environment for the IL code to run, and you can run code written in any language after it has been converted to MSIL code by its specific compiler, and you can even write the MSIL code on the CLI itself. As. NET and the central part of the CLR, the CLI and C # also obtained ECMA approval (ECMA-335). With both the C # and CLI standards, you can write your own to run on any operating system. NET platform (as long as you wish). As mentioned earlier, the famous mono project is doing this, and the mono project consists of three core parts: A C # language compiler, a CLI, and a class library. what is the CLR.

The CLR (Common Language Runtime) Common language runtime is a "runtime" that can be used by a variety of programming languages. The core capabilities of the CLR, such as memory management, assembly loading, security, small exception handling, and thread synchronization, can be shared by all the languages of the CLR. what IL is.

Il intermediate language, Dot Net's program after the formation of the Il Code, in the runtime when the CLR compiles the cost of CPU instructions. The IL code is also called managed code. Il can access all the capabilities of the CLR. Il can also be viewed as an object-oriented machine language that can be written using assembly language. Il Advantage is that it verifies the correctness of the code (number of arguments, validation of parameter types)

What the JIT is and how it works. JIT (Just in time) Just-in-time compiler, invoked by the CLR, compiles the IL to a cost CPU instruction.

When a piece of code is invoked for the first time, the CLR points to a special function contained within the CLR, which is the jitcompiler,jitcompiler responsible for compiling the IL to the cost of the instruction. Jitcompiler knows which method is actually invoked, and the method is of those type definitions, Jitcompiler finds the IL of the invoked method in the metadata of the assembly that defines the type, and compiles the IL to the CPU instruction of the cost. The result of the compilation is placed in a block of memory, and then Jitcompiler returns the internal data structure created by the CLR for the type, finds the record that corresponds to the actual calling method, and modifies the original reference to Jitcompiler. To point to the address of the CPU instruction in the memory block that the called method has just been compiled. The CPU instruction that finally executes the invoked method. What is GC, a brief description of how the GC works.

Garbage collection (garbage collection)

Dot Net garbage collection can be divided into two steps, the first step is "tag", the garbage collector assumes that all objects are garbage, and then begins to traverse each "root" (the root contains a pointer to a reference type object, which is never considered a root), If a root is found to refer to an object (not null), the object is marked. Objects that are not marked are considered rubbish. The second phase is "compression", in fact, is to move the object in the back of the object has become garbage, so that the original managed heap more compact. Thus freeing the managed heap.

Methods in the GC class affect when objects are garbage collected and when the resources allocated by the objects are freed. The properties in this class provide information about the total amount of memory available to the system, the cycle category (generation) of memory allocated to the object.

The GC tracks and reclaims objects allocated in managed memory. The garbage collector periodically performs garbage collection to reclaim memory allocated to objects that do not have a valid reference. Garbage collection occurs automatically when the memory request is not satisfied with available memory. Alternatively, the application can use the Collect method to force garbage collection.

Garbage collection consists of the following steps:

The GC searches for managed objects referenced in managed code.

GC attempts to complete an object that is not referenced.

The GC frees the objects that are not referenced and reclaims their memory.

During a recycle, if the GC finds one or more references to an object in managed code, the object is not disposed. However, the GC does not recognize references to objects in unmanaged code, so it is possible to release objects that are used exclusively in unmanaged code unless explicitly prohibited. The KeepAlive method provides a mechanism that prevents the garbage collector from reclaiming objects that are still used in unmanaged code.

So much to answer only one question and welcome everyone to talk about making bricks

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.