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

  • Home
  • SEARCH
  • 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 6974949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:18:13+00:00 2026-05-27T17:18:13+00:00

What makes t a rooted reference (stay in scope) ? ( t is a

  • 0

What makes t a rooted reference (stay in scope) ? (t is a user defined class)

I look at in in IL spy, and its not a common capture variable !

Action runs = null;
while (dummy <= tod.Value.Date)
{
   var t = new Task(dummy, _interval);
   runs += t.Run;

   dummy = dummy.AddDays(1);
}
GC.Collect();
((Action)(() => { runs(); })).BeginInvoke(Result, null);

Can someone explain this to me? How the t (task) classes stay in scope, what makes it rooted, I guess its the runs delegate, but how?

  • 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-05-27T17:18:14+00:00Added an answer on May 27, 2026 at 5:18 pm

    Firstly, I should point out that this doesn’t have much to with scope, which is the region of program text in which one can refer to an entity using its simple name. It’s about reachability.

    Now I haven’t looked at the heap in question with a memory profiler, but the path to a Task object would look something like this:

    1. The Action (multicast) delegate instance is a GC root since it is referenced by runs (a local).
    2. This delegate instance in turn keeps its individual subscribers alive through its _invocationlist field, which holds a reference to a delegate array.
    3. This array in turn contains references to the individual (unicast) Action delegate instances.
    4. Each of these individual delegates will be a closed-instance delegate with a populated _target field (which will act as the this reference passed to the Task.Run method when the delegate is invoked). This field will hold a reference to the Task instance.

    To summarize:

        runs local
    -> Multicast Action object
    -> (through _invocationlist field) Array of references to Action objects
    -> (through a specific array element) Unicast Action object
    -> (through _target field) Task object
    

    UPDATE:

    I ran this through Ants Memory Profiler, which confirmed my thoughts:

    Path to Task object

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

Sidebar

Related Questions

VC++ makes functions which are implemented within the class declaration inline functions. If I
Intel makes microprocessor, so he could define the instruction format and its corresponse assembly
What makes actors so lightweight? I'm not even sure how they work. Aren't they
Follow up question from What is a "rooted reference"? consider this code, for a
What makes a language a scripting language? I've heard some people say "when it
Grails makes it very easy to configure datasources for different environments (development, test, production)
What Makes a Good Unit Test? says that a test should test only one
XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite
What makes Python stand out for use in web development? What are some examples
It makes sense that something like an operating system would be written in C.

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.