dcsimg
erasing a vector that contains vectors
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ivn_Tcakov
Posted On:   Monday, October 15, 2001 11:33 AM

Hello,
I have a question about vectors.
Suppose I have vector of vectors. If I decide to erase this,
is it enough to erase the first vector without erasing
the vectors that it contains? Or do I have to go through
the whole vector and erase all the vectors it contains
and then erase the main vector?
As much as I remember, this is a serious issue in C
programming but I think I heard that java doesn't have a
problem with this.
Thanks
Ivan

Re: erasing a vector that contains vectors

Posted By:   George_McKinney  
Posted On:   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.
About | Sitemap | Contact