×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Releasing Memory
2

Releasing Memory

Releasing Memory

(OP)
I'm using quite a bit of VBA code in a excel spreadsheet, and everytime the code executes, memeory usage goes up by about 100K, according to Task Manager. This memory is never released, and available memory just becomes less and less with each execution. Is there some procedure I can write at the end of my code to release the memory?

RE: Releasing Memory

That will depend on what you're doing, and where in the VBA code you're doing it.  Most likely, you're allocating memory for dynamic objects but not release those objects when you're done.  Have you narrowed things down to one or more specific sections of code, and if so, what are you doing in those sections?
 

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Releasing Memory

(OP)
The code is full of altering and filling in cell ranges. Sometimes individual cells, sometimes cell groups. I know that a range of cells is considered an object in vb's eyes, but i have not named each object individually. I am hoping there is a general way to release ram when procedure is complete.

RE: Releasing Memory

When writing VB code, it's a good idea to release all of your objects by setting them to nothing. It's less important with variables decalared as strings, or other types, but application objects should be set to nothing. i.e.:

dim objRange as Excel.Range

blah blah magic code blah.

' we're done with the range, so clean up.
set objRange = Nothing\

 

Tim Grote - The Irrigation Engineers.
www.irrigationengineers.com

RE: Releasing Memory

Check if you have globally declared arrays or objects. They will not dissappear when code execution is over. Clean up at the end of routine:
Erase MyArray()
Set MyObject = Nothing

But it could be some of Excel problems as well.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources