How can garbage collectors be faster than explicit memory deallocation?

后端 未结 4 459
遥遥无期
遥遥无期 2021-02-03 10:41

I was reading this html generated, (may expire, Here is the original ps file.)

GC Myth 3: Garbage collectors are always slower than explicit memory deallocation.
GC

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 11:27

    One approach to make GC faster then explicit deallocation is to deallocate implicitly :

    the heap is divided in partitions, and the VM switches between the partitions from time to time (when a partition gets too full for example). Live objects are copied to the new partition and all the dead objects are not deallocated - they are just left forgotten. So the deallocation itself ends up costing nothing. The additional benefit of this approach is that the heap defragmentation is a free bonus.

    Please note this is a very general description of the actual processes.

提交回复
热议问题