Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to remove an instance of COM object from memory?

Status
Not open for further replies.

mtchary

Programmer
Mar 4, 2004
18
CA
HI
In a program I create an instance of registered COM object, and assign a reference to the local variable.
loObject = CREATEOBJECT(“Component.ComponentClass”)
After the program is finished VFP still keep instance of the COM object in a memory. So next time I run my program it uses previously created object, instead of creating new one.
What should be done to avoid this behavior?

TIA
 
frmMyForm = CREATEOBJECT("FormGrandChild")


RELEASE frmMyForm


Attitude is Everything
 
The best app I have come accross: and download Process Explorer. This free (!) utility will show ALL running processes including the COM-object. You can easily terminate it and have it removed from memory. I do this to make sure everything has unloaded before I do an update etc.
Works like a charm.

Regards,

Ron
 
Or how about a function will terminate any processes you pass through it. (from faq184-4140)

Function to terminate all instances of a running process.

FUNCTION terminateProcess(lcProcess)
lcComputer = "."
loWMIService = Getobject("winmgmts:" ;
+ "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ;
("Select * from Win32_Process")
For Each loProcess In colProcessList
IF UPPER(loProcess.name) = lcProcess
loProcess.terminate()
endif
Next


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top