N
Novice
Hi, I am doing some work with Java and C++ and am curious as to whether self
references in Java cause memory leaks.
For example:
class Test{
Object foo =this;
}
If I instantiate Test, the reference count of any Test object will never
become zero (as it always keeps a reference to itself) so long as the foo
variable is never re-assigned.
Does this present a problem for Java's garbage collection?
Thanks,
Novice
references in Java cause memory leaks.
For example:
class Test{
Object foo =this;
}
If I instantiate Test, the reference count of any Test object will never
become zero (as it always keeps a reference to itself) so long as the foo
variable is never re-assigned.
Does this present a problem for Java's garbage collection?
Thanks,
Novice