. NET garbage collection workstation and server differences

Source: Internet
Author: User

Always thought that. NET garbage collection is single-threaded, the original can actually be concurrent.

workstation and server garbage collection comparison

The following are thread handling and performance considerations for workstation garbage collection:

  • recycle occurs on the user thread that triggered the garbage collection and retains the same priority.   because the user thread typically runs at normal priority, the garbage collector (running on a normal priority thread) must compete with other threads for CPU time.

    does not suspend threads that run native code.

  • Workstation garbage collection is always used on computers with only one processor, regardless of the <gcServer> settings. If you specify server garbage collection, the CLR uses workstation garbage collection and disables concurrency.

The following are threading and performance considerations for Server garbage collection:

  • provides a heap and a dedicated thread for each CPU to perform garbage collection, and the heap is reclaimed at the same time.   Each heap contains a small object heap and a large object heap, and all of the heaps can be accessed by user code.   objects on different heaps can be referenced by each other.

  • because multiple garbage collection threads work together, server garbage collection is faster than workstation garbage collection for heaps of the same size.

  • server garbage collection usually has a larger segment.   However, note that this is typically the case: the segment size is implementation-specific and may change.   you adjust the application, you should not assume that the garbage collector allocates the segment size.

  • server garbage collection consumes a lot of resources.   For example, if you have 12 processes running on a computer with 4 processors, there will be 48 dedicated garbage collection threads in case they are all using server garbage collection.   in the case of high memory load, if all processes start performing garbage collection, the garbage collector will plan 48 threads.

If you are running hundreds of instances of an application, consider using workstation garbage collection and disabling concurrent garbage collection. This can improve performance by reducing context switching.

ref:https://msdn.microsoft.com/zh-cn/library/ee787088 (v=vs.110). aspx

. NET garbage collection workstation and server differences

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.