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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:58:52+00:00 2026-05-26T18:58:52+00:00

This is a basic Question for all programming languages, But I am much familiar

  • 0

This is a basic Question for all programming languages, But I am much familiar with VBA.So Im using the vba code. I got some doubt with deallocating the memory.Does the performance degarde when we erase or swap off the allocated contents ?
something like

Method I where we deallocate the allocated memory

sub my_function()
     Dim a() as string
     redim a(1 to 15)
     'some for loop  goes here aroung 50 iterations
     erase a ' Deallocate the array
     ' some piece of code goes here may be 40 lines
end sub

Method II where we dont deallocate any memory

sub my_function()
     Dim a() as string
     redim a(1 to 15)
     'some for loop  goes here aroung 50 iterations
     'some piece of code goes here may be 40 lines
end sub

Method III where we dellocate memory at the last statment

sub my_function()
     Dim a() as string
     redim a(1 to 15)
     'some for loop  goes here aroung 50 iterations
     'some piece of code goes here may be 40 lines
     erase a 'deallocate the memory
end sub

The question

Method I is erase a, Does it eat up any huge cycles ? or more bytes of ram ? or should i wait for the end of the sub routine or should I go for using erase statement

Method II There is no erase statement in the sub routine, the function kills the array at the end of sub routine but I dont need the array till the end of function so is this fast enough or optimized?

Method III At the first watch, people say its a foolish thing to dellocate at the end of the sub routine as itself kills at the end,But I am eager to know Thanks

  • 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-26T18:58:52+00:00Added an answer on May 26, 2026 at 6:58 pm

    The answer will somewhat depend on the language used and how large the memory being used is.
    For VBA in 99.99% of all the cases I can imagine there is no performance gain from deallocateing array memory, and its probably marginally slower.
    There are rare cases in VBA where it is worthwhile explicitly destroying objects.

    For languages such as C/C++ that do not automatically handle memory deallocation it is important to explicitly program memory deallocation so that your code does not contain a memory leak.

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

Sidebar

Related Questions

This is very basic question from programming point of view but as I am
This is very basic magento question i guess. I want to first get all
Forgive my ignorance in asking this basic question but I've become so used to
This might be basic question but how do I create a list of lists
This might be basic question, however I am confused on some .Net Concpets. I
I know this maybe a basic question but I just can't seem to find
I realize this is a basic question but I have searched online, been to
I am new in programming and this question may really be stupid but I
This is a basic question - when spring bean is loaded and if i
I am relatively new to XSL and I think this is a basic question.

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.