MSComm obj.

A

AA

Hi
I am developing an app in which I have used a MSComm object. I have opened
the
port, performed the transactions, and then closed the port.
But when I check in the task mamager, the memory being held by the MSComm is
not being released. I am using the SetPortOpen method.
Is there any way of releasing this memory explicitly.
Regards.
 
J

Jagadeesh VN

I have read somewhere about MSComm control creating an extra copy of data
when GetInput(...) is invoked, and that can be solved by using Attach method
of COleVariant.

COleVariant var = MSComm1.GetInput();
This makes an extra copy of the data and leaves it lying around.
Instead use this...
COleVariant var;
var.Attach (MSComm1.GetInput());

Then you can access the data using SafeArrayAccessData. Don't forget to use
SafeArrayUnaccessData for unlocking...

Cheers
Jagadeesh
 
A

AAg.

Thanks for your immediate help Jagadeesh.
However, please look at my issue below : This code is from MSDN :
MSComm mlComm;

mlComm.SetCommPort(1);

mlComm.SetInBufferSize(1024);

mlComm.SetOutBufferSize(512);

mlComm.SetSettings("9600,n,8,1");

mlComm.SetInputMode(1);

mlComm.SetRThreshold(0);

mlComm.SetSThreshold(0);

// try catch loop

try

{

m_ctlComm.SetPortOpen(TRUE);

}

catch(CException* e)

{

AfxMessageBox("Open already. Please check!!. ",MB_ICONSTOP);

return FALSE;

}

It is taking around 3.5 MB space, which is not released even after I return
to the main app after closing the port.

Please suggest.
 
J

Jagadeesh VN

I think, its taking some memory for the initialization. Even if you create
another instance of MSComm, then the memory usage wont go up. It happens
only for the first time.
 
A

AAg.

Hi Jagadeesh
Without the MSComm GetInput also, it is giving the same memory usage.
Can there be any other API or method to explicitly clear this memory?
Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top