Results 1 to 4 of 4

Thread: garbage collector

  1. #1
    Contributing Member
    Join Date
    Mar 2007
    Answers
    34

    Red face 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


  2. #2
    Junior Member
    Join Date
    Mar 2007
    Answers
    2

    Re: garbage collector

    Quote Originally Posted by rohit dwivedi9450 View Post
    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
    We have destructors in C++. We have to use as follows
    ~classname(){ Give the items to be garbage collected or nullified}


  3. #3
    Expert Member
    Join Date
    Oct 2005
    Answers
    383

    Re: garbage collector

    Quote Originally Posted by rohit dwivedi9450 View Post
    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
    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

    As far as c or c++ is concerned we have to handle

    :)
    NEVER SAY DIE.

  4. #4
    Junior Member
    Join Date
    Nov 2006
    Answers
    26

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact