Garbage Collector in C# - Managed Heap Efficiently

Shervan360 1,481 Reputation points
2022-09-28T00:22:24.027+00:00

Please see the following:
https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals#benefits

They wrote:

Allocates objects on the managed heap efficiently.

What does mean efficiently here? Which criteria are considered?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,496 Reputation points Microsoft Vendor
    2022-09-28T07:12:26.643+00:00

    @Shervan360 , Welcome to Microsoft Q&A, you could also read the Microsoft learning fundamentals to know how it allocates the objects efficiently.

    First, GC can allocate memory for each new object continuously as long as the memory space.

    Second, Allocating memory from the managed heap is faster than unmanaged memory allocation due to adding a value to a pointer.

    Third, an application can access the objects quickly because the new objects are stored contiguously in the managed heap.

    From the above points, We could know that Allocates objects on the managed heap efficiently.

    Hope my explanation could help you.

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful