View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
vivmaha vivmaha is offline
external usenet poster
 
Posts: 42
Default VBA memory allocation

Thanks, but this isnt the reason. I am selecting the right ones to delete.

"Jim Cone" wrote:


One possible cause...
Adding a member to a collection without specifying an index causes
the member to be appended to the end of the collection.
So to remove the most recent addition you would use...
myCollection.Remove myCollection.Count

If you want to remove the entire collection from memory then...
Set myCollection = Nothing
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"vivmaha"
wrote in message
Hi,

I'm running a huge model on VBA, and I think i'm leaking memory.

In the following example, does the memory allocated for myInstance get freed
when I remove it from the collection? I assume that, like java, once the
memory is not referenced to, It gets deallocated.

dim myCollection as Collection
Set myCollection = new Collection
dim myInstance as MyClass
Set myInstance = new MyClass
myCollection.add myInstance
myCollection.remove 1

If the above does not free the memory, how do I do it?

Also, does VBA have constructors? And destructors?

Thanks.