By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

MSComm obj.

P: n/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.
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"AA" <no*@noreply.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 17 '05 #2

P: n/a
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.
"Jagadeesh VN" <ja*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

"AA" <no*@noreply.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
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.


Nov 17 '05 #3

P: n/a
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.
"AAg." <no*@noreply.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
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.
"Jagadeesh VN" <ja*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

"AA" <no*@noreply.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
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.



Nov 17 '05 #4

P: n/a
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.
"Jagadeesh VN" <ja*********@hotmail.com> wrote in message
news:u6**************@TK2MSFTNGP11.phx.gbl...
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.
"AAg." <no*@noreply.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
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.
"Jagadeesh VN" <ja*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

"AA" <no*@noreply.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
> 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.
>
>



Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.