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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:11:16+00:00 2026-06-09T03:11:16+00:00

I have a question about garbage collection when an object seemingly falls out of

  • 0

I have a question about garbage collection when an object seemingly falls out of scope but may still stay alive as other classes are still holding references to it. Please look through the code below. Thanks.

Public Class MainForm

    Private Sub Work
         Dim Obj1 as New DataTable
         Dim Obj2 as New DataTable

         Helper.TestMethod1(Obj1)
         Helper.TestMethod2(Obj2)
    End Sub

End Class

Public Class Helper

     Private Shared Obj1Reference as Object

     Public Shared Sub TestMethod1 (ByVal obj1Ref as Object)
         Obj1Reference = obj1Ref
     End Sub

     Public Shared Sub TestMethod2 (ByVal obj2Ref as Object)
          'Do Something with obj2Ref
     End Sub

End Class

Would both Obj1 and Obj2 be put on the garbage collection queue after the Work method exits. From my understanding, Obj2 is put on the queue but not Obj1 as the static helper class is holding a reference to Obj1. Please correct me if I am wrong.

  • 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-09T03:11:18+00:00Added an answer on June 9, 2026 at 3:11 am

    Nothing is collected because neither of your objects have been initialized and are therefore both Nothing. If they were initialized, then yes, one would continue to exist because it would continue to have a reference to it and the other would not because it would not have a reference to it.

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

Sidebar

Related Questions

I have a question about how garbage collection might be handled in a linq
I have simple question about .net garbage collection. In the following code I create
Once again a question about the garbage collector in actionscript-3: If I have a
I have question about XSLT1.0. The task is to write out in HTML all
My question may duplicate Default implementation for Object.GetHashCode() but I'm asking again because I
I'm re-reading CLR via C# right now and have some questions about garbage collection
I asked a question about this method: // Save an object out to the
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about normalization. Suppose I have an applications dealing with songs. First

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.