|
-
Jun 25th, 2001, 05:28 AM
#1
Thread Starter
Member
setting objects to Nothing
hi
i am creating an new object every time and then at the end of
what i am doing i then set it to nothing
set obj = new COMobj
set obj = nothing
but this seems to be leaking / increasing the memory
does this nothing statement actually work - does it destroy
the obj or is there another way of doing this
thanks
Louby
-
Jun 26th, 2001, 03:59 AM
#2
You're doing it right.
The question is, does the object that is being set to nothing do it's own memory cleaning? ie: when the obj_Terminate event fires, is it cleanijng up any objects that it might be holding?
- gaffa
-
Jun 27th, 2001, 07:16 PM
#3
For example -
Unless you're at sp5 in VB 6.0 the MSChart control leaks memory like a sieve.
The answer depends on what object you're referencing, not that you personally are writing poor code.
-
Jun 27th, 2001, 08:10 PM
#4
Hyperactive Member
I guess I have two comments. First, when you set an object to nothing, memory and system resources are not immediately released. The reason is that VB does a lot of garbage collection that you, the programmer, do not see, and sometimes it just takes VB a while to clean up the object resources. Second, setting an object to nothing doesn't release all system resources until the variable falls out of scope. So if your object is a global variable, even after it has been set to nothing, the variable will still retain some resources.
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|