Does a garbage collector collect stack memory, heap memory, or both?

前端 未结 9 2754
独厮守ぢ
独厮守ぢ 2021-02-19 04:13

I read lot of articles about garbage collection and almost all article tells about heap memory. so my question is \"garbage collection collects stack memory or heap memory or bo

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-19 04:36

    the stack is where your method arguments and local variables lie. if you leave the method, the stack pointer is automatically decremented (or incremented depending on the specific implementation). This is true for most programming languages.

    garbage collection in contrast only works on the heap.

提交回复
热议问题