4 ms·
> You can still have memory leaks in GC-d languages by reference cycles. public class T { Object ref; @Override protected void finalize(
by fctorial 6y ago
> You can still have memory leaks in GC-d languages by reference cycles.
public class T {
Object ref;
@Override
protected void finalize() {
System.out.println("finalize");
}
static void leak() {
T a = new T(), b = new T();
a.ref = b;
b.ref = a;
}
public static void main(String[] as) throws Throwable {
leak();
System.gc();
Thread.sleep(10000);
}
}