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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:41:49+00:00 2026-05-15T19:41:49+00:00

Is there a difference from POV Performance / MemoryUsage initializing a object before, or

  • 0

Is there a difference from POV Performance / MemoryUsage initializing a object before, or after a return condition, like in the “sample”:

Function Foo() as ComplexObject

    ' is there a difference ??? '
    ' A '
    ' Dim obj as New ComplexObject() ' 

    If condition Then Return Nothing

    ' is there a difference ??? '        
    ' B '
    Dim obj as New ComplexObject()
    ...
    Return obj

End Function
  • 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-15T19:41:50+00:00Added an answer on May 15, 2026 at 7:41 pm

    If you mean, but comparison to:

     Dim obj as New ComplexObject()
    

    before the If condition Then Return Nothing, then yes: there is a difference: it done before, then it will new an object each time, even if it is quickly discarded and collected from gen-0 (for the case when Nothing is returned). However, if you just declare it (without New) before the If, then the two should be identical (the position of the local variable is irrelevant, since all locals in IL are method-wide).

    I don’t know the VB, but in C# you could also use a conditional operator:

    return condition ? null : new ComplexObject();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to do this you will need to use… May 17, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer A pure virtual function may have a definition (out of… May 17, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer I solved that problem using the Django middleware system and… May 17, 2026 at 2:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

is there a difference, from prospective of meta-programming for example, between the two declarations?
I am interested if there is any difference from the C or C++ compiler
I have a page that displays data from an object. I'm loading the object
After fighting with different things here and there, I was finally able to get
I am trying to consume data from a webservice published by a 3rd party.
I realize that it seems to be a duplicate of What is the difference
I have a cube with a typical snapshot structure and daily granularity (like inventory
I am just wondering. Do I need to call System.exit(0); right before main method
Hi I'm migrating a few databases from sql 2000 to sql 2008. while running
I wonder now, what is the difference between the two methods: DataInputStream.skipBytes and DataInputStream.skip

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.