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 7729953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:06:01+00:00 2026-06-01T06:06:01+00:00

I was wondering about : How GC sees the Lazy object i.e. : Lazy<Foo>

  • 0

I was wondering about : How GC sees the Lazy object

i.e. :

 Lazy<Foo> f = new Lazy<Foo>( );

“Lazy Instantiation” defers creation of an object till the time it is actually accessed

Does f here is a root for the object ? ( meaning he wont be GC’ed ) ?

( the object is not created by this time… some other code put a value in it later on)

or

GC sees it as un-referenced / un-initialized object – and GCe’d it.

Is it something which I need to take care of ? ( / fear of ?)

 public class Foo
    {
        public int ID { get; set; } 
        public Foo()
        {
           ID = 1;
        }
    }
  • 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-01T06:06:02+00:00Added an answer on June 1, 2026 at 6:06 am

    f is indeed a reference to the Lazy<Foo> instance. The encapsulated Foo instance is separate but is made (kept) reachable indirectly.

    As long as f exists, ie it is a root or it is reachable, the instance won’t be (can’t be) collected.

    There is really nothing special regarding GC here. Don’t confuse Lazy with WeakReference.

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

Sidebar

Related Questions

I was wondering about the time complexity of the shuffle function in the random
I'm currently wondering about composing an object/class/trait that conforms to one trait for multiple
Just wondering about the performance impact of copying very large php variables. For example
Just wondering about this code below... when I turn off my internet connection and
Just wondering about some practice about this; I have made a simple visual C#
I was wondering about caching dynamic PHP pages. Is it really about pre-compiling the
I was wondering about ?? signs in C# code. What is it for? And
I have been wondering about the reload() function in python, which seems like it
I been wondering about this for a while. It seems like there are so
I am wondering about the reliabilty of message delivery in messaging systems such as

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.