.Net interview eight-part essay question and answer sharing

The previous article shared a .Net interview eight-part article, and many friends asked for answers. Due to space and time limitations, this article will talk about the answers to the first 25 questions. You can follow a wave of public accounts ( jianghupt ) and will continue to share later

Friendly reminder, you may be able to get answers to these questions on some AIs. But please note that AI’s answer to this kind of question is specious and very wrong and misleading.

Here are the conclusions drawn by the author through years of research on CLR/JIT (please feel free to correct me if there are any omissions) for reference:

1.Net GC recycling steps
answer: marking, planning, relocation, compression, cleaning

2. What are cross-generation object references?
Answer: Object references between different generations. For example, a second-generation object references a transient heap object.

3. Which heap is the string stored in
? Answer: .Net7 is in the GC heap, and .Net8 is outside the GC heap.

4. What is the root object and how to release it
? Answer: Local reference variables are generally released by the compiler.

5. The meaning of fixed objects.
Answer: The handle of an unmanaged object will not be moved by GC in the GC heap.

6. Explain, strong reference handle, weak reference handle.
Answer: The object indicated by the strong reference handle cannot be recycled, but the object indicated by the weak reference handle can be recycled.

7. How does the destructor run?
Answer: The destructor thread is notified through the kernel object, takes out the destructor list heap (FinalizerListSeg) or the object containing the destructor in the key destructor list heap, and runs the destructor.

8. When does GC enable upgrading?
Answer: When executing 2nd generation GC recycling

9. How is the binary tree constructed in the GC planning phase?
Answer: The construction of binary tree vertices and leaf nodes is mainly determined by odd and even numbers.

10. How does GC mark objects as alive?
Answer: Save the root object through JIT compilation GCInfo, and remove the root object recursively during GC.

11. How does GC re-determine the target generation
? Answer: When the threshold is exhausted or low latency is required

12. There are several types of threads that execute GC.
Answer: three, background thread, workstation thread, and server thread.

13. Overall GC process
Answer: Stop other threads, determine the target generation for recycling, (marking, planning, relocation, compression, cleaning), end

14. Calculation of assigned thresholds.
Answer: Calculation through coefficients and fragmentation rates. It is very complicated. The formula will be listed later.

15. What is the difference between allocating small objects and large objects
? Answer: There is a big difference in the size of allocated space, with 85000 bytes as the limit.

16.How does the new keyword allocate objects?
Answer: Allocate by allocating context or through API, divided into fast and slow

17. The process of generational implementation
Answer: Each CPU core is divided into four generations, three small object generations (0,1,2), and one large object generation (2)

18. What are managed heaps, heap segments, regions, and allocation contexts?
Answer: The objects allocated for storage, the memory division of the CPU core, the memory of the CPU core, and pointers to allocated objects.

19. Function memory model
Answer: There are five main ones, namely

MethodTable,MethodDesc,PreCode,Fixup,MethodDesChunk

20.AOT compilation process
Answer: Compile the source code into a target file through ILC, link the target file through the llvm backend, and generate the target machine executable file

21.What is ILC?
Answer: AOT compiler

21. Where are the survival marks and fixed marks stored, and on which bits
? Answer: They are stored in MT (type information), which are divided into the last bit and the high three bits respectively.

22. Type information (MT), object header (ObjHeader), their functions.
Answer: MT is mainly used to distinguish which object it is, and Objheader is mainly used for thread synchronization and other functions.

23. The difference between heap space and stack space.
Answer: The heap needs to be released manually, while the stack is automatically released by the compiler.

24. How do delay mode, GC mode, and reserved heap space address optimize GC?
Answer: Mainly through the GC mechanism of CLR, environment variables can control whether it is optimized.

25. What is the IR of JIT?
Answer: Intermediate representation, mainly the layer of code between JIT’s MSIL and machine code

 

Author: Jianghu Commentary.

Original address: .Net interview eight-part essay question and answer sharing

OpenAI opens ChatGPT Voice Vite 5 for free to all users. It is officially released . Operator's magic operation: disconnecting the network in the background, deactivating broadband accounts, forcing users to change optical modems. Microsoft open source Terminal Chat programmers tampered with ETC balances and embezzled more than 2.6 million yuan a year. Used by the father of Redis Pure C language code implements the Telegram Bot framework. If you are an open source project maintainer, how far can you endure this kind of reply? Microsoft Copilot Web AI will be officially launched on December 1, supporting Chinese OpenAI. Former CEO and President Sam Altman & Greg Brockman joined Microsoft. Broadcom announced the successful acquisition of VMware.
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/5407571/blog/10141626
Recommended