How much extra memory does garbage collection require?

后端 未结 4 1352
死守一世寂寞
死守一世寂寞 2021-02-07 13:45

I heard once that for a language to implement and run garbage collection correctly there is on average of 3x more memory required. I am not sure if this is assuming the

4条回答
  •  被撕碎了的回忆
    2021-02-07 14:18

    I hope the original author clearly marked what they regard as correct usage of garbage collection and the context of their claim.

    The overhead certainly depends on many factors; e.g., the overhead is larger if you run your garbage collector less frequently; a copying garbage collector has a higher overhead than a mark and sweep collector; and it is much easier to write a garbage collector with lower overhead in a single-threaded application than in the multi-threaded world, especially for anything that moves objects around (copying and/or compacting gc).

提交回复
热议问题