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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:06:41+00:00 2026-05-26T09:06:41+00:00

Every once and a while, I have to get the basics to a language

  • 0

Every once and a while, I have to get the basics to a language after long coding excursions. In VB.Net, I understand declarying a variable as an object type more or less creates a reference to it.

Take the following code:

Dim obj1 as Object
Dim obj2 as Object
obj1 = new Object
obj2 = new Object
obj1 = obj2

A very elementary set of tasks, but I am trying to figure out what exactly is going each step of the way. This is my understanding: Line 1, obj1 is declared as an Object type and the compiler creates a reference for obj1 to hold, but what is obj1 referencing at the end of line 1?(are nothing and null synonymous?) Line 2 is the same as line 1 except its a different variable. Line 3, the compiler allocates space in the heap for a new object and passes the reference to obj1 1 to hold. Line 4 is the same as line 3. The part that I’ve never been quite clear on is the the 5th line. obj1 is assigned to the same reference as obj2 so they are both pointing the same object in memory. So what happens to the object that obj1 was originally assigned in line 3? Once obj1 takes the same reference as obj2, does that leave the first new object left in memory with no way to access it (or at least until garbage collection starts)?

  • 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-26T09:06:42+00:00Added an answer on May 26, 2026 at 9:06 am

    What is obj1 referencing at the end of line 1?

    In VB parlance it’s pointing to Nothing, which is the same as C#’s null (which in this instance you can think of as pointing to memory location zero).

    Once obj1 takes the same reference as obj2, does that leave the first
    new object left in memory with no way to access it (or at least until
    garbage collection starts)

    Yes, that’s exactly what happens. With the vagaries of garbage collection, you can never tell when this will actually be collected, and indeed, there is no guarantee that it will ever be collected.

    Let the GC worry about that sort of stuff, don’t try to “help” it, unless you really (and dude I seriously mean really) need to.

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

Sidebar

Related Questions

Every once and a while I get this error in IE when making an
I have a multithreaded .NET Windows Service that hangs intermittently -- maybe once every
I have a VS 2008 VB.NET Solution, which is quite large. Every once in
I have a PHP script running as a daemon. Every once in a while,
We get CoreData could not fulfill a fault every once in a while. We
Every once in a while, typically when I stop debugging in our UI assembly,
Im using Visual studio 2008. Every once in a while files that exist in
I have a web scraping script that gets new data once every minute, but
Every once in a while, I need to build a character separated string while
Every once in a while, when I'm editing an aspx or ascx page, Visual

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.