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 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

Related Questions

In general (or from your experience), is there difference in performance between for and
is there any performance difference between: SELECT * FROM table WHERE id IN (1,2,3)
When working with content loaded asynchronously is there any difference from a performance point
is there a difference between HttpPost from mvc2 and AcceptPost, PostOnly attributes from mvccontrib
Is there any difference between these two LINQ statements: var query = from a
How do I prevent my SWF from decompiling? Is there any difference between ActionScript
I have to admin there is slight difference between the columns from both tables.
I am interested if there is any difference from the C or C++ compiler
Are there any performance concerns of note when using MySQL's CONCAT() function in a
Is there any difference between using the field ID or _ID from a MongoDB

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.