Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2014, 06:44 AM
whatsup whatsup is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Quote:
Although it's good practice, I doubt that cleaning up after the 'Set' variables makes a material difference to the execution speed.
Paul, you partly right - if you haven't got a big bunch of variables remaining in the memory it won't affect speed significantly. But in times of automation many people aren't aware of this issue but wonder why excel gets slow during working and that's one point (of many) to look at.
Memory assigned is restricted to 512 MB no matter of the size of RAM available. In filling up the "pot" it slows down speed.
Reply With Quote
  #2  
Old 06-14-2014, 06:08 PM
BobBridges's Avatar
BobBridges BobBridges is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

In the middle of the run I can believe it could make a difference. But you did the two Set=Nothings at the very end of the program, right? It isn't obvious to me how that could make even an immeasurable difference. Am I missing something?
Reply With Quote
  #3  
Old 06-15-2014, 06:44 PM
whatsup whatsup is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Bob, I'm erasing set object variables from memory manually out of two reasons:
- Variables created within a macro should be erased from memory automatically once the macro is done. With set objects in former times it didn't always work this way and you were left to an error of stackoverflow in the worst case or to a poor performance. Since I don't know if the problem is fixed, I just continue erasing them manually.
- The main reason: There are different types of objects, for instance classes you must unload manually; if creating a new instance of an object (whenever using the keyword "New") you have to unload it manually as well - even more important because depending of the object it might use huge capacity in memory. Now, tell me are there more? Lazy as I am, I don't want to think about it neither look it up, but destroy each of them manually once they did their job. And it's not a big deal to write the additional instructions.
Reply With Quote
  #4  
Old 06-15-2014, 09:20 PM
BobBridges's Avatar
BobBridges BobBridges is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I think you're saying that if I don't free an object manually, there are circumstances where it might not be freed by the VBA editor as the macro comes to an end. I don't think I ever knew that (or if I did, I forgot). That does make a difference, especially because I tend to leave my laptop on for a week or three at a time and Excel is unlikely to be closed at any time during that period. Run macros again and again, and this could get to be a problem.

Well, I don't know that I'll change my habits overnight. But at least I'm sure to be suspicious if things slow down suddenly, in the near future; I may discover that I'm well advised to do the same as you.
Reply With Quote
  #5  
Old 06-18-2014, 08:12 PM
whatsup whatsup is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Bob, I forgot
Quote:
Originally Posted by BobBridges View Post
...That does make a difference, especially because I tend to leave my laptop on for a week or three at a time and Excel is unlikely to be closed at any time during that period...
I'm quite curious about the results you get in respect of memory allocation when trying the tool CoolBlue provided (DictionarySearch).
Leaving excel for long periods open in my opinion will result in any case that things slow down. I would expect that memory allocation after at least one day equals the limit. But I can't tell by experience, because usually I close excel at least every hour, unless it's doing calculations, but than memory is used to the limit.
Reply With Quote
  #6  
Old 06-18-2014, 08:38 PM
whatsup whatsup is offline Slow "comparison/replace" script Windows 7 64bit Slow "comparison/replace" script Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Interesting:
Features: switch Set To Nothing = False, switch Throw Error = True

Code:
23:25:33:0697 Call RangeCompare2: Don't Set to Nothing:     WorkingSetSize  60.395.520  ( Reference )
23:25:33:0707 Start Timer:                 t = 0.000 sec:   WorkingSetSize  60.403.712  ( 8.192 )
23:25:33:0717 arrCompare Loaded:           t = 0.008 sec:   WorkingSetSize  61.366.272  ( 970.752 )
23:25:33:0747 objDic Loaded:                                WorkingSetSize  61.693.952  ( 1.298.432 )
 ERROR: 450: Wrong number of arguments or invalid property assignment 
23:25:33:0747 after End Sub:                                WorkingSetSize  60.719.104  ( 323.584 )
The difference between Start and End (323.584) remains out of 40 runs 30 times the same, equals once, and for the rest it differs just slightly +/-
What can we make of this?

CoolBlue, I enjoy playing with your tool
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd "script code" in a downloaded .doc file CNBarnes Word 2 10-18-2012 02:07 AM
Slow "comparison/replace" script replace data from variable with "sub and super script" from excel to word by vba krishnaoptif Word VBA 9 06-22-2012 05:08 AM
Slow "comparison/replace" script How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
Rules and Alerts: "run a script"? discountvc Outlook 0 06-15-2010 07:36 AM
An "error has occurred in the script on this page" decann Outlook 8 09-03-2009 08:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft