Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had read that its good practice to set instances of class to Nothing
to free up the memory. Is there garbage collection in VBA? Also is there any benefit to setting Application Object Model class variables to Nothing upon exiting a procedure or function? For example Dim myRange as Range Set myRange = Something Do some code Set myRange = Nothing Exit Function Or is the memory allocated in the function returned to the heap when the function goes out of scope? *** Sent via Developersdex http://www.developersdex.com *** |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Or is the memory allocated in the function returned to the heap when the
function goes out of scope? For local variables, Yes. -- Regards, Tom Ogilvy "Edward Ulle" wrote in message ... I had read that its good practice to set instances of class to Nothing to free up the memory. Is there garbage collection in VBA? Also is there any benefit to setting Application Object Model class variables to Nothing upon exiting a procedure or function? For example Dim myRange as Range Set myRange = Something Do some code Set myRange = Nothing Exit Function Or is the memory allocated in the function returned to the heap when the function goes out of scope? *** Sent via Developersdex http://www.developersdex.com *** |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Read this NG post by Matthew Curland http://tinyurl.com/cq95p
-- HTH Bob Phillips (remove nothere from email address if mailing direct) "Edward Ulle" wrote in message ... I had read that its good practice to set instances of class to Nothing to free up the memory. Is there garbage collection in VBA? Also is there any benefit to setting Application Object Model class variables to Nothing upon exiting a procedure or function? For example Dim myRange as Range Set myRange = Something Do some code Set myRange = Nothing Exit Function Or is the memory allocated in the function returned to the heap when the function goes out of scope? *** Sent via Developersdex http://www.developersdex.com *** |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To both of you thanks.
I've been wasting my time and fingers typing Set all class variables to Nothing at the end of all my procedures. Good article Bob. *** Sent via Developersdex http://www.developersdex.com *** |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Edward,
Unfortunately, whilst Matthew is making a very good point (and he is a respected MS developer), there are cases, automation comes to mind, where not clearing down the objects is suspected of being the reason why Excel sometimes fails to quit. -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Edward Ulle" wrote in message ... To both of you thanks. I've been wasting my time and fingers typing Set all class variables to Nothing at the end of all my procedures. Good article Bob. *** Sent via Developersdex http://www.developersdex.com *** |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
I understand there are circumstance that explicit releasing of resource is required. In my case, I have a macro that is constantly running. It displays a modeless dialog box with numerous options. I have only a few of my own classes. Generally I'm using the Excel Object Model classes. Each option of the dialog box fires up another module to do some processing of data. Once that module is finished the procedure is exited and control returns to the main dialog box module. Almost alway the class instances are local to the module and can be release. So my concern was does multiple calls to the modules cause accumulation of memory locks or is it released. As Tom pointed out, if they are local I don't have to explicit release. Thanks. *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I delete an infinite number of garbage cells to the right | Excel Discussion (Misc queries) | |||
Excel opening w/ garbage | Excel Discussion (Misc queries) | |||
MSCOMM returning garbage as input | Excel Programming | |||
Deleting garbage | Excel Programming | |||
delete garbage from worksheet | Excel Programming |