- Posts: 70
- Thank you received: 0
Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- Can Develop OPC XML DA C++ client in Visual Studio 2015?
Can Develop OPC XML DA C++ client in Visual Studio 2015?
Attached performance counter file and its running around 40 mins only after that its crashing (out of memory exception), at that time of crash, memory is 1.6 GB. Every 1.6 GB of memory leak this exception is reproduced very well, refer attached image of exception too.
Please do let me know the solution ASAP, My Management is pushing me address this at earliest.
Thanks for understanding.
Please Log in or Create an account to join the conversation.
Use PERFMON, the "Private bytes" counter for the process.
Please Log in or Create an account to join the conversation.
Still Memory leak is there, In 1 minute below code reaches to 3.5 MB. I have incorporated your change and put while loop in sample ReadMultipleItems. Could you please check the issue.
while(1){
_DAReadItemArgumentsPtr ReadItemArguments1Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments1Ptr->ServerDescriptor->ServerClass = L"OPCLabs.KitServer.2";
ReadItemArguments1Ptr->ItemDescriptor->ItemId = L"Simulation.Random";
_DAReadItemArgumentsPtr ReadItemArguments2Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments2Ptr->ServerDescriptor->ServerClass = L"OPCLabs.KitServer.2";
ReadItemArguments2Ptr->ItemDescriptor->ItemId = L"Trends.Ramp (1 min)";
_DAReadItemArgumentsPtr ReadItemArguments3Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments3Ptr->ServerDescriptor->ServerClass = L"OPCLabs.KitServer.2";
ReadItemArguments3Ptr->ItemDescriptor->ItemId = L"Trends.Sine (1 min)";
_DAReadItemArgumentsPtr ReadItemArguments4Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments4Ptr->ServerDescriptor->ServerClass = L"OPCLabs.KitServer.2";
ReadItemArguments4Ptr->ItemDescriptor->ItemId = L"Simulation.Register_I4";
CComSafeArray<VARIANT> ArgumentsArray(4);
ArgumentsArray.SetAt(0, _variant_t((IDispatch*)ReadItemArguments1Ptr));
ArgumentsArray.SetAt(1, _variant_t((IDispatch*)ReadItemArguments2Ptr));
ArgumentsArray.SetAt(2, _variant_t((IDispatch*)ReadItemArguments3Ptr));
ArgumentsArray.SetAt(3, _variant_t((IDispatch*)ReadItemArguments4Ptr));
LPSAFEARRAY pArgumentsArray = ArgumentsArray.Detach();
//CComSafeArray<VARIANT> ResultArray(ClientPtr->ReadMultipleItems(&pArgumentsArray));
[b] CComSafeArray<VARIANT> ResultArray;
ResultArray.Attach(ClientPtr->ReadMultipleItems(&pArgumentsArray));[/b]
ArgumentsArray.Attach(pArgumentsArray);
for (int i = ResultArray.GetLowerBound(0); i <= ResultArray.GetUpperBound(0); i++)
{
_DAVtqResultPtr DAVtqResultPtr(ResultArray[i]);
_DAVtqPtr DAVtqPtr(DAVtqResultPtr->Vtq);
_variant_t vtqAsString(DAVtqPtr->ToString);
_tprintf(_T("results(%d).Vtq.ToString(): %s\n"), i, vtqAsString.bstrVal);
}
// Release all interface pointers BEFORE calling CoUninitialize()
ResultArray.Detach();
ResultArray.Destroy();
ArgumentsArray.Detach();
ArgumentsArray.Destroy();
}
Please Log in or Create an account to join the conversation.
It should instead be written like this:
CComSafeArray<VARIANT> ResultArray;
ResultArray.Attach(ClientPtr->ReadMultipleItems(&pArgumentsArray));
Regards
Please Log in or Create an account to join the conversation.
Do you guys have any update for me?
Thanks.
Please Log in or Create an account to join the conversation.
Best regards
Please Log in or Create an account to join the conversation.
Below code is consistently growing up even after destroying it, How do I clear the memory for pArgumentsArray, ResultArray and ArgumentsArray. I doubt its destroying array but memory is not cleaned.
I call this thread for every 5, 26 secs and 1 subscription based thread also running. When I enter this point of code memory is growing up then after its not reducing at all.
I just checked by running ExampleCOM - ReadMultipleItems for memory, its also taking 16+MB.
Since, I am licensed user can I get different version of QuickOPC libraries where I can get reduced memory leak.
When I run this application in client environment within 1 hour it reaches to 100MB and in 12 hours it goes more then 1GB which is not acceptable by my customer.
Please help me to solve this issue.
_EasyDAClientPtr ClientPtr(__uuidof(EasyDAClient)); ---> This line grows up almost 13MB after that its not freed at all. In my code I am calling only once to check server connection, read multiple items and subscribe multiple items.
for (int i = 0; i < noOftags; i++)
{
_DAReadItemArgumentsPtr ReadItemArguments1Ptr(_uuidof(DAReadItemArguments));
ReadItemArguments1Ptr->ServerDescriptor->UrlString = urlString.m_str;
ReadItemArguments1Ptr->ItemDescriptor->ItemId = itemIds.m_str;
ArgumentsArray.SetAt(i, _variant_t((IDispatch*)ReadItemArguments1Ptr));
}
LPSAFEARRAY pArgumentsArray = ArgumentsArray.Detach();
CComSafeArray<VARIANT> ResultArray(ClientPtr->ReadMultipleItems(&pArgumentsArray)); ----> This line grows up almost 1.2MB each time.
ArgumentsArray.Attach(pArgumentsArray);
ResultArray.Destroy();
ArgumentsArray.Destroy();
//SafeArrayDestroy(pArgumentsArray);
Please Log in or Create an account to join the conversation.
If the memory consumed by the process truly grows beyond reasonable amounts (how much?), then try to determine which part(s) of the code are responsible. There are tools that tell you where the allocations are being made. You can also comment out parts of the code and observer the effect is has. For example, if you are using subscriptions, the first candidate would be to comment out the whole body of the event handler, to see if it's coming from there.
Mind you, it is fairly easy to cause a memory leak in C or C++.
Please Log in or Create an account to join the conversation.
Thanks for the input.
I application crashed after 36 hours and gave error logs is QuickOPC libaries. Could you please check and help me solve this issue or any clue to fix these issues.
I have customized error logs for better reading and attached the same.
Thanks.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- Can Develop OPC XML DA C++ client in Visual Studio 2015?