Garbage Collection

后端 未结 6 1802
暗喜
暗喜 2021-02-04 15:55

I am not able to understand few things on the Garbage collection.

Firstly, how is data allocated space ? i.e. on stack or heap( As per my knowledge, all static or globa

6条回答
  •  再見小時候
    2021-02-04 16:21

    You might find the short summary of Garbage Collection on the Memory Management Reference useful.

    Ultimately, garbage collection has to start at the registers of the processor(s), since any objects that can't be reached by the processor can be recycled. Depending the the language and run-time system, it makes sense to assume statically that the stacks and registers of threads are also reachable, as well as “global variables”.

    Stacks probably get you local variables. So in simple GCs you start by scanning thread contexts, their stacks, and the global variables. But that's certainly not true in every case. Some languages don't use stacks or have global variables as such. What's more, GCs can use a barrier so that they don't have to look at every stack or global every time. Some specialised hardware, such as the Symbolics Lisp Machine had barriers on registers!

提交回复
热议问题