C# - Garbage Collection

前端 未结 9 823
闹比i
闹比i 2021-01-31 11:15

Ok so I understand about the stack and the heap (values live on the Stack, references on the Heap).

When I declare a new instance of a Class, this lives on the heap, wit

9条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 11:42

    First off, to Erics seminal post about The truth about value types

    Secondly on Garbage collection, the collector knows far more about your running program than you do, don't try to second guess it unless you're in the incredibly unlikely situation that you have a memory leak.

    So to your second question, no don't try to "help" the GC.

    I'll find a post to this effect on the CG and update this answer.

提交回复
热议问题