class A {
void execute(){
B b = new B(this);
}
}
class B {
A a;
public B(A a){
this.a = a;
}
}
메모리 힙에 A클래스 객체 a_root가 잇음.
a_root는 절대 GC에서 회수 안되고, a_root.execute()를 대충 10만번 때렷다 치자.
풀GC돌린후에 힙상에 B객체는 10만개 남아잇을까?
A가 B를 참조할순 없으니 참조 끊어졋다 판단하나?
- dc official App
GC 쿨돌면 다사라짐 - dc App
B를 참조하는놈이 엄으니까 - dc App