Re: erasing a vector that contains vectors
Monday, October 15, 2001 01:19 PM
If by "erase" you mean "set to null", then you only need to set the parent Vector to null. IF (and only IF) there are no other references to the "child" Vectors the parent contains, then those children will be eligible for Garbage collection.
If some other part of the system is holding references to the child Vectors, then they will NOT be garbage collected (and the same is true of the parent Vector).
The most common way to create a "memory leak" in Java is to have some long-lived Collection hold on to other Objects that are no longer of any use to the rest of the app. This isn't a leak in the C sense, because there is still a reference to the memory, but it has much the same effect.