+ Reply to Thread
Results 1 to 9 of 9

is there a way to clear memory?

  1. #1
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    is there a way to clear memory?

    Hi,

    sometimes excel reaches a point in which while I have VBE editor open always complains ouf "out of memory"
    even in the immediate panel, writing "? 1+1" results in "Out of Memory"

    is there a way to free memory, other than closing all excel applications and launch them again ?

    note: this error is not in run-time

    regards!

  2. #2
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: is there a way to clear memory?

    Hi,
    I would suggest you that there may be some issue with your machine or into your code..
    There are several ways to reduce the memory depends on your code.......
    Can I have a look on your code......
    Lokesh Kumar
    Stay Hungry.. Stay Foolish..
    _________________________________________________________
    Please Click STAR to Add Reputation if my/someone's answer helped!

  3. #3
    Forum Contributor
    Join Date
    03-11-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    379

    Re: is there a way to clear memory?

    Hi Bagullor,

    Hope this should help
    Please Login or Register  to view this content.
    Regards,
    AM

  4. #4
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: is there a way to clear memory?

    hi ashishmehra2010,
    actually I use that already in many of my macros

    let's imagine that there is some "bad" macro out there that books a lot of memory and never releases it.
    Excel then starts complaining about "out of memory" even when the macro has already finished.

    is there some way to free all memory without closing and opening excel?

  5. #5
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: is there a way to clear memory?

    Quote Originally Posted by bagullo View Post
    hi ashishmehra2010,
    actually I use that already in many of my macros

    let's imagine that there is some "bad" macro out there that books a lot of memory and never releases it.
    Excel then starts complaining about "out of memory" even when the macro has already finished.

    is there some way to free all memory without closing and opening excel?
    Hi
    I already assuming that you already had this in your code.....it can slow or fast your code only to some extent....."Out of memory" happened when your code is using CPU memory a lot....
    I am still saying if you can show your code with workbook.....then only I can look into it....otherwise it would be not possible......

  6. #6
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: is there a way to clear memory?

    Hi Lokesh,

    I am not trying to solve a problem with the code, but rather trying to find a general procedure to release memory.
    From your answers I asume there is none, and that the only way to solve the problem is to check the root cause and solve it there.

    oh well.

    thanks for your time guys.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: is there a way to clear memory?

    You can workaround this issue
    Try this code that closes the workbook and opens it again without saving changes
    It will of course clear memory
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: is there a way to clear memory?

    Hey,

    See if you have been working with VBA from very long period. Then you know all the ways of reducing memory.........these 2 are main.
    The main reason behind the memory is the "Variant", if you declare 100 variables explicitly(string,long,data and so on) and you declare 100 variant then you know what would be the result. Always declare variable type rather then Variant.
    Again the best practice is when you have a very long code with lots of variable then split the code and call the next sub and so on (you will never run out of memory)....and when you are finishing a code release the memory.....like
    Erase Array()
    Set object to nothing
    If you still think that VBA has lots of data in memory then try pasting some of the data in worksheet and fetch it and delete it when needed......

    Hope that helps.....

  9. #9
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: is there a way to clear memory?

    Thank you YasserKhalil -- had not thought of that

    thank you lokeshKumar -- I mostly follow the good practices you mention
    I like breaking down procedure into smaller ones, but I don't like putting too many parameters in each function... so I use probably too many public variables
    also I know about the variant issue, but I like how you can initialize arrays by doing arr= array(....) but only works with variant

    thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loops - Clear cache/memory problem
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 10:23 AM
  2. Need VBA to find out memory and virtual memory used by thread
    By Yozhik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 08:31 AM
  3. How to clear memory while running a macro
    By Hjahren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2010, 10:04 AM
  4. Clear Clip Board Memory
    By James_Newton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2005, 08:07 PM
  5. [SOLVED] Do you wish to clear clipboard memory?
    By WendyUK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1