 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Since
Java provides garbage collection
|
|
|
– |
There
are no destructors
|
|
|
– |
But…have
you ever had a destructor do something other
|
|
|
than
memory deallocation?
|
|
|
– |
If
you need this – you must write a named function and call
|
|
it
explicitly!! (maybe called : void cleanup()?)
|
|
|
| • |
If
for some reason you do need some kind of garbage
|
|
|
collection
done that the garbage collector doesn’t know
|
|
|
about
(like C or C++ memory allocation is being used-not
|
|
|
recommended!)
|
|
|
– |
You
can write a method called “finalize()” which the
|
|
|
garbage
collector will implicitly call if it is provided prior
|
|
|
to
releasing memory –
|
|
|
– |
and
then on the next garbage collection pass it will reclaim
|
|
|
the
object’s memory
|
|