Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I set a variable to a new object, does the old value die?

Assume I have a variable, which is a List(Of T), with 100 elements that are instances of a class....

If I set this variable to a new List(Of T) with another 100 instances, the old ones totally disappear, right? They...die. Absolutely thing of the past, right?

like image 668
Voldemort Avatar asked Jan 26 '26 20:01

Voldemort


1 Answers

Assuming nothing else points to those 100 things, then yes, they are eligible for garbage collection.

like image 73
Adam Rackis Avatar answered Jan 29 '26 11:01

Adam Rackis