문제

I read somewhere that Garbage collection is not like destruction(in the C++ sense). how they are different?

도움이 되었습니까?

해결책

C++ destruction is deterministic, garbage collection is not.

In C++ you can guarantee when destructors will be called, in Java there is no such guarantee at all. In fact, your destructors might never be called in Java.

다른 팁

  • Destructor is called before an object is about to be deleted (Whether it is on the stack or heap)
  • Garbage collection will go through your program every now and then checking to see if there are any variables that are no longer being used and delete them
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top