B
Ben
Say i have a static queue in class A.
I instantiate class B and in the constructor I instantiate an object of
class A just to get a reference of the static queue.
Once the constructor finishes there is no reference to any object of
class A, just it's queue.
Later on I instatiate several objects of class A that will all add to
the queue.
So the question is:
if I don't have a reference to any object of class A, but I have a
reference to it's static queue, will the "lost" reference to class A I
used in the constructor be collected by the garbage collector? If yes
once a new object is constructed will the static queue have the same
address, or will a new address be given to it?
And if the address is the same, but the "lost" reference is not
collected can I take care of that memory leak, and keep the reference of
the static queue?
I instantiate class B and in the constructor I instantiate an object of
class A just to get a reference of the static queue.
Once the constructor finishes there is no reference to any object of
class A, just it's queue.
Later on I instatiate several objects of class A that will all add to
the queue.
So the question is:
if I don't have a reference to any object of class A, but I have a
reference to it's static queue, will the "lost" reference to class A I
used in the constructor be collected by the garbage collector? If yes
once a new object is constructed will the static queue have the same
address, or will a new address be given to it?
And if the address is the same, but the "lost" reference is not
collected can I take care of that memory leak, and keep the reference of
the static queue?