-
garbage collector
hi..............................>>
to all my net friends iwant to know that in java we use garbage collector for terminating un wanted memory space .
i want to know yhat in c or c++ is there any kind of garbage collector or we use it with free?
please help me in this i 'ii be greatful:confused:
-
Re: garbage collector
[QUOTE=rohit dwivedi9450;9090]hi..............................>>
to all my net friends iwant to know that in java we use garbage collector for terminating un wanted memory space .
i want to know yhat in c or c++ is there any kind of garbage collector or we use it with free?
please help me in this i 'ii be greatful:confused:[/QUOTE]
We have destructors in C++. We have to use as follows
~classname(){ Give the items to be garbage collected or nullified}
-
Re: garbage collector
[QUOTE=rohit dwivedi9450;9090]hi..............................>>
to all my net friends iwant to know that in java we use garbage collector for terminating un wanted memory space .
i want to know yhat in c or c++ is there any kind of garbage collector or we use it with free?
please help me in this i 'ii be greatful:confused:[/QUOTE]
hi rohit
first of all i would like to say that its not us who call garbage collector!
Garbage collector is called by JVM itself when it feels that there is no enough memory!but when it will run and free memory is not under our control!
this gc thread has the least priority!
ofcourse java do provide us with System.gc() which allows us to call garbagecollector explicitly but still we cannot be sure that even after calling it explicitly it will free the resources immediately!
Java has many advantages.One of such advantages is that programmer doesnot have to look after memory(explicitly).(THOUGH some measures have to be taken).
But in c, c++ you have to manage memory explicitly!You must have come across delete,malloc etc.Similarly you must have used destructors in c++!You will notice here that all are done explicitly!
I hope i am clear
:D
As far as c or c++ is concerned we have to handle
-
Re: garbage collector
hi rohit,
in addition to vmshenoy and kayal in c we also have a method free() which is also used for free the memory. generally we use it in data structures.
Thanks and regards