Click here to Skip to main content
15,903,033 members
Home / Discussions / COM
   

COM

 
QuestionHow to detect ActiveX on IE when it begins run using BHO? Pin
Blue-Bird1-Mar-06 21:09
Blue-Bird1-Mar-06 21:09 
QuestionUsing ActiveX in MFC Pin
lroels1-Mar-06 20:36
lroels1-Mar-06 20:36 
Questionout of process activex exe Pin
david_reynolds28-Feb-06 9:16
david_reynolds28-Feb-06 9:16 
AnswerRe: out of process activex exe Pin
Roger Stoltz28-Feb-06 21:23
Roger Stoltz28-Feb-06 21:23 
GeneralRe: out of process activex exe Pin
david_reynolds1-Mar-06 3:11
david_reynolds1-Mar-06 3:11 
QuestionHow to delete a COM object - My Other Code Pin
AmitGG27-Feb-06 22:45
AmitGG27-Feb-06 22:45 
AnswerRe: How to delete a COM object - My Other Code Pin
AmitGG28-Feb-06 22:14
AmitGG28-Feb-06 22:14 
QuestionHow to delete a COM object Pin
AmitGG27-Feb-06 20:30
AmitGG27-Feb-06 20:30 
I have a C# (managed code) DLL and I am accessing this DLL's functions from C++ (unmanaged code) using COM.

I create a COM object with CoCreateInstance function. Then I do work on this object. After that I call Release() function on this object. But after calling Release() function the object is not destroyed automatically. After calling Release function I called some more functions on this object and all those calls were successful.

I called CoCreateInstance only once and there is only one reference of this object in my code. I also checked the return value of Release function call which is ZERO which shows the reference count of the object is ZERO and it should automatically destroy the object as soon as the reference count becomes ZERO. But in my case the object is not destroyed.

Actually in my project work I have to create and destroy the COM object many times (1000-2000). So in each iteration the memory size is increasing and after some iteration it becomes more than 1 GB and fills all the page file space and the program hangs.

Could Anybody suggest me how to delete the COM object.





The code I am using is following :

#include<iostream.h>
#include <afxmt.h>
#include <comdef.h>
#include<string.h>
#import "mscorlib.tlb" raw_interfaces_only
#import "Flowmaster.Automation.Gui.tlb" no_namespace named_guids
#import "Flowmaster.Automation.Analysis.tlb" no_namespace named_guids

class CFDlinkDoc
{
IFM2_AnalysisControl* m_pAnalCntrlv7;
BSTR sDataSource;
BSTR sDataBase;
BSTR sProject;
BSTR sUserName;
BSTR sPassword;
BSTR Project;
BSTR NetworkName;
BSTR Description;
BSTR Owner;
int ResultID;
public:
CFDlinkDoc();
void func1();
};


CFDlinkDoc::CFDlinkDoc()
{
m_pAnalCntrlv7 = NULL;
sDataSource = L"pcpune26";
sDataBase = L"FM100206";
sProject = L"Flowmaster";
sUserName = L"Admin";
sPassword = L"";
Project = L"Flowmaster";
NetworkName = L"AmitG";
Description = L"Hi, COM testing From C++";
Owner = L"AG";
}

void CFDlinkDoc::func1()
{
HRESULT hr = CoInitialize(NULL);
hr = CoCreateInstance(__uuidof(FM2_AnalysisControl) ,NULL, CLSCTX_INPROC_SERVER, __uuidof(IFM2_AnalysisControl), reinterpret_cast<void**>(&m_pAnalCntrlv7));


long lP= m_pAnalCntrlv7->DatabaseLogin(sDataSource, sDataBase, sProject, sUserName, sPassword);
m_pAnalCntrlv7->PutProjectName(Project);
m_pAnalCntrlv7->PutNetworkName(NetworkName);
m_pAnalCntrlv7->PutDescription(Description);
m_pAnalCntrlv7->PutOwnername(Owner);
m_pAnalCntrlv7->PutAnalysisType(_T("SS"));
m_pAnalCntrlv7->PutHeatTransfer(0);
if(m_pAnalCntrlv7->Initialise() == 0)
cout<<"Failed to initialise network";

m_pAnalCntrlv7->RunToCompletion();

m_pAnalCntrlv7->Release();
m_pAnalCntrlv7 = NULL;

CoUninitialize();
}

void main()
{
CFDlinkDoc CFDlink = CFDlinkDoc();

for(int i = 0 ; i <1000 ; i++)
{
CFDlink.func1();
}
}

-- modified at 4:25 Tuesday 28th February, 2006
AnswerRe: How to delete a COM object Pin
mbue27-Feb-06 22:07
mbue27-Feb-06 22:07 
GeneralRe: How to delete a COM object Pin
AmitGG27-Feb-06 22:21
AmitGG27-Feb-06 22:21 
GeneralRe: How to delete a COM object Pin
mbue27-Feb-06 23:29
mbue27-Feb-06 23:29 
GeneralRe: How to delete a COM object Pin
AmitGG28-Feb-06 0:05
AmitGG28-Feb-06 0:05 
GeneralRe: How to delete a COM object Pin
mbue28-Feb-06 3:51
mbue28-Feb-06 3:51 
QuestionConnecting Multiple clients to single server using DCOM Pin
abhiramsss27-Feb-06 18:21
abhiramsss27-Feb-06 18:21 
AnswerRe: Connecting Multiple clients to single server using DCOM Pin
FearlessBurner6-Mar-06 1:51
FearlessBurner6-Mar-06 1:51 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
abhiramsss8-Mar-06 19:10
abhiramsss8-Mar-06 19:10 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
abhiramsss9-Mar-06 23:31
abhiramsss9-Mar-06 23:31 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
FearlessBurner10-Mar-06 0:18
FearlessBurner10-Mar-06 0:18 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
abhiramsss12-Mar-06 20:09
abhiramsss12-Mar-06 20:09 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
abhiramsss13-Mar-06 22:30
abhiramsss13-Mar-06 22:30 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
FearlessBurner16-Mar-06 4:25
FearlessBurner16-Mar-06 4:25 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
abhiramsss19-Mar-06 21:24
abhiramsss19-Mar-06 21:24 
GeneralRe: Connecting Multiple clients to single server using DCOM Pin
FearlessBurner22-Mar-06 6:51
FearlessBurner22-Mar-06 6:51 
QuestionAutomation Server Can't Create Object Pin
bigmacrox27-Feb-06 12:46
bigmacrox27-Feb-06 12:46 
AnswerRe: Automation Server Can't Create Object Pin
mbue27-Feb-06 16:18
mbue27-Feb-06 16:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.