Destructors
A
destructor is a special method typically used to perform cleanup after an
object is no longer needed by the program. C++ supports destructs, but JAVA does not support destructors.
It make destroy
of objects to make memory free
to get feature use of memory of ram .
There
memory of heap and stack both will make free because objects get memory if heap
and stack full then there will be an error. After destructor called…
1:- first
of all stack memory will full because of thread store directly in to stack and
object also but thread can store only in stack not store in heap
Exception
will generate if memory will full
Stack out
of memory exception will generate.
First of
all stack will full then heap will not make continue to assignee or running
application if stack overflow then heap will not work.
If stack
give exception then heap will not work
Heap is
depended on stack;
Syntax:-
Class Name()
Garbage Collection
The
garbage collector is a part of the runtime system that runs in a low-priority thread
reclaiming memory that is no longer needed by objects used by the program. An
object becomes eligible for garbage collection in JAVA when there are no longer any
reference variables that reference the object.
Syntax:-
System.gc();
No comments:
Post a Comment