Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:37:39+00:00 2026-06-13T11:37:39+00:00

Suppose an object has a Finalize() method. When it is first created, a pointer

  • 0

Suppose an object has a Finalize() method.

When it is first created, a pointer in the finalization queue was added.

The object has no references .

When a garbage collection occurs, it moves the reference from the finalization queue to the f-reachable queue and a thread is started to run the Finalize method (sequentially after other objects’ Finalize methods).

So the object now (after resurrection) has only one root which is the pointer from the f-reachable queue.

At this point, does/did the object get promoted to the next generation ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:37:40+00:00Added an answer on June 13, 2026 at 11:37 am

    This is something you can just try. Run this code in the Release build without a debugger attached:

    using System;
    
    class Program {
        static void Main(string[] args) {
            var obj = new Foo();
            // There are 3 generations, could have used GC.MaxGeneration
            for (int ix = 0; ix < 3; ++ix) {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            Console.ReadLine();
        }
    }
    
    class Foo {
        int attempt = 0;
        ~Foo() {
            // Don't try to do this over and over again, rough at program exit
            if (attempt++ < 3) {
                GC.ReRegisterForFinalize(this);
                Console.WriteLine(GC.GetGeneration(this));
            }
        }
    }
    

    Output:

    1
    2
    2

    So it stays in the generation it got moved to by the collection, moving to the next one on each collection until it hits the last one. Which makes sense in general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a customer object that has all of the standard customer properties
Suppose I have a UserControl whose DataContext is set to an object that has
suppose i have object has key 'dlist0' with attribute 'row_id' the i can access
suppose Object A has a list of Object B, and Object B must have
I have an arrayList of object Player. Player has field id, and score. suppose
Suppose I have a design like this: Object GUI has two objects: object aManager
Suppose I have 50 objects in an array and each object has the property
Suppose Object A has a property: @property (nonatomic, strong) Foo * bar; Synthesized in
Suppose I have a class called Object. The Object class has a member function
Suppose an object travels in a parabola in 2D coordinate system from P to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.