Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / January 2004



Tip: Looking for answers? Try searching our database.

Finding active objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Glaser - 03 Jan 2004 20:27 GMT
I have an ActiveX Dll that I have implemented using VB 6.0.

The DLL implements 50 differrnt kind of com objects that have
references to each other.  The problem I have is that when the client
exe finishes execution, it does not termnate because there are DLL
objects that have not terminated.  So how do I find those objects that
are not terminated?
Norm Cook - 04 Jan 2004 14:37 GMT
Unless I miss the point of your post, this is just part of good programming
practice.  You have to keep up with the objects you instantiate & destroy
them (set = Nothing) when done.  In other words, for every object you set to
something, you must also, at some point, set it to nothing.  Realizing that
setting an object to nothing calls the class terminate event of the class,
you can also do some cleaning up in each terminate event.

> I have an ActiveX Dll that I have implemented using VB 6.0.
>
[quoted text clipped - 3 lines]
> objects that have not terminated.  So how do I find those objects that
> are not terminated?
David Glaser - 04 Jan 2004 15:24 GMT
Yes, of couse one should practice safe programming.  However, when
programming in the large, it is nice to have a tool that will tell you
that there are active objects so that you can zero in on the area that
needs fixing.  After all, C++ programmers have a facility that tells
them that  there are memory leaks and says where the object was
allocated.

So, if VB does not have such a facility, does the COM runtime facility
provide a way to discover acitive interfaces in a process?

-David
>Unless I miss the point of your post, this is just part of good programming
>practice.  You have to keep up with the objects you instantiate & destroy
[quoted text clipped - 10 lines]
>> objects that have not terminated.  So how do I find those objects that
>> are not terminated?
Joe - 04 Jan 2004 17:49 GMT
> I have an ActiveX Dll that I have implemented using VB 6.0.
>
[quoted text clipped - 3 lines]
> objects that have not terminated.  So how do I find those objects that
> are not terminated?

With your own objects, you could put tracking stuff in each and every
Class_Initialize and Class_Terminate event:

----module globals-----

global objects as new collection
----

private sub class_initialize()
 objects.add typename(me) & " at " & hex$(objptr(me)), "x" & hex$(objptr(me))
end sub

private sub class_terminate()
 objects.remove "x" & hex$(objptr(me))
end sub

...or you could use the "objects" collection to store "weak references"
if you want to be able to interrogate the objects in the list.

--
Joe Foster <mailto:jlfoster%40znet.com>  Sign the Check! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!
David Glaser - 04 Jan 2004 19:01 GMT
Oooooo,  good idea.  Danke.

>> I have an ActiveX Dll that I have implemented using VB 6.0.
>>
[quoted text clipped - 22 lines]
>...or you could use the "objects" collection to store "weak references"
>if you want to be able to interrogate the objects in the list.
Peter Huang - 06 Jan 2004 01:42 GMT
Hi David,

Based on my experience, there is no methods to find active objects. So you
have to track the COM objects' creation and destruction yourself.

I think Joe Foster's suggestion is a good method.
If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security 
This posting is provided "as is" with no warranties and confers no rights.
Laser Lu - 26 Jan 2004 07:27 GMT
I've met the same problem that COM objects can not be released after the
client program has been terminated.

Signature

Best regards,
Laser Lu

> I have an ActiveX Dll that I have implemented using VB 6.0.
>
[quoted text clipped - 3 lines]
> objects that have not terminated.  So how do I find those objects that
> are not terminated?
Laser Lu - 26 Jan 2004 09:58 GMT
And I wanna know the reason why the objects can not be released or need too
much long time to be released?

Signature

Best regards,

> I've met the same problem that COM objects can not be released after the
> client program has been terminated.
[quoted text clipped - 6 lines]
> > objects that have not terminated.  So how do I find those objects that
> > are not terminated?
Eduardo A. Morcillo [MS MVP VB] - 26 Jan 2004 15:53 GMT
> And I wanna know the reason why the objects can not be released or
> need too much long time to be released?

Circular references are usually the reason. If object A references object B, and B references A then both objects are keeping the other alive. You have to force one of the objects to release the other (by calling a method) to release and destroy them.

Signature

Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.