Results 1 to 6 of 6

Thread: What is the difference between a destructor and a finalizer?

  1. #1
    Join Date
    Dec 2009
    Posts
    18

    What is the difference between a destructor and a finalizer?

    I am fresher(beginner programmer) in the Java programming world. And i am also learning other programming language like C++, C sharp, Visual Basic 6, DBMS and PHP. Actually i have gone through lessons of destructor and finalizer. And now i am confused that what is difference between them(i.e destructor and finalizer). Please somebody give knowledge about this.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is the difference between a destructor and a finalizer?

    The destructor and finalizer are function which are also used in C sharp as well as Java also. The finalizer's are consider as not deterministic, while a destructor's are consider as deterministic. The destructor will run when the program will explicitly frees the object. A finalizer, by contrast, is executed when the internal garbage collection system frees the object. In this way, both destructor and finalizer differs from each other.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the difference between a destructor and a finalizer?

    According to me, the destructor as well as finalizer are the mechanisms which is used for cleaning up a resource when they are no longer in the use. I was also thinking that there is no difference between both of them, until my professor explain me about it. My professor told me, that destructor is mainly used to mean a deterministically-invoked cleanup, whereas a finalizer runs when the garbage collector says it to run.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What is the difference between a destructor and a finalizer?

    My knowledge about programming language says that the destructor's is mainly used or invoke after it is called by programmer. In other words, if the programmer will forget to call destructor, then variable lives in the memory and is not destroyed. But the finalize method is invoke/run by itself. Finalizers are not deterministic and destructor are deterministic. Hope you will be able to understand the destructor and finalize method.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: What is the difference between a destructor and a finalizer?

    Mostly all the new programmer will feel that the destructor and finalizer works(operates) in same manner, but no its not like that. I would say that the only difference that can be known between the destructor and finalizer is that the destructor's are mainly used for cleanup methods which will be invoke deterministically, and whereas finalizers will be running when the garbage collector tells them to run. Hope you will be able to understand my points.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: What is the difference between a destructor and a finalizer?

    I think this(i.e destructor and finalizer) are mechanism used for cleaning up the resource which are no longer in use by the program. But both the mechanism are very different from each other. The destructor is used as deterministically invoked cleanup and on the other side the finalizer will run or used when the garbage collector says to run it. In other words, the finalizer will be invoke by itself only, and destructor will be invoke after it is called by programmer. Hope your problem is fix.

Similar Threads

  1. Replies: 3
    Last Post: 28-08-2012, 12:05 PM
  2. Problem in LinkedList destructor.
    By KAIRU26 in forum Software Development
    Replies: 5
    Last Post: 15-02-2010, 07:14 PM
  3. Basic use of destructor
    By Sacchidananda in forum Software Development
    Replies: 3
    Last Post: 19-11-2009, 10:20 AM
  4. Destructor in PHP5
    By Duck in forum Software Development
    Replies: 3
    Last Post: 18-03-2009, 12:01 AM
  5. Destructor in Java
    By Anti_Trend in forum Software Development
    Replies: 7
    Last Post: 25-10-2008, 03:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,522,296.89491 seconds with 17 queries