From: R.
Sent: Friday, May 13, 2011 6:26 PM
Subject: Data-COM Memory issue
.....
I have a customer who is complaining about a memory leak issue in the Data-COM. [.....] the application code is in VC++ [....] I haven’t been able to identify where in his code the memory increase is coming from. I have attached the sample application he sent me.
He says that if you run it as is, the memory increases- commenting out the WriteMultipleTags call causes the memory to be stable- so it is something in this routine I would guess. As far as I can tell he is destroying the tagValues and tagNames array each time- so it doesn’t seem to be from adding the tags continually to it. Any other ideas?
> ================================
> bool COpcClient::TestWriteBoolTags(const TCHAR * name1, const TCHAR * name2,
> bool val1, bool val2) {
>
> CComSafeArray tagValues;
> CComSafeArray tagNames;
>
> tagValues.Add(_variant_t(val1));
> tagNames.Add(CComBSTR(name1));
>
> tagValues.Add(_variant_t(val2));
> tagNames.Add(CComBSTR(name2));
>
> try {
> VARIANT v1, v2;
> VariantInit( &v1 );
> V_VT( &v1 ) = VT_ARRAY + VT_BSTR;
> SAFEARRAY * aNames = tagNames;
> V_ARRAY( &v1 ) = aNames;
>
> VariantInit( &v2 );
> V_VT( &v2 ) = VT_ARRAY + VT_VARIANT;
> SAFEARRAY * aValues = tagValues;
> V_ARRAY( &v2 ) = aValues;
>
> _variant_t varMachineNames(m_HostName);
> _variant_t varServerClasses(m_ServerName);
> _variant_t varStates=vtMissing;
> _variant_t varDataTypes=vtMissing;
> _variant_t varAccessPaths=vtMissing;
>
> VARIANT _result;
> VariantInit(&_result);
> HRESULT _hr =
> m_EasyDAClientPtr->raw_WriteMultipleItemValues(varMachineNames,
>
> varServerClasses,
> v1,
> v2,
>
> varStates,
>
> varDataTypes,
>
> varAccessPaths,
>
> &_result);
>
> if (FAILED(_hr)) _com_issue_errorex(_hr, m_EasyDAClientPtr,
> __uuidof(EasyDAClient));
>
> return true;
> }
> catch (_com_error e) {
> return false;
> }
Any help would be appreciated.
R.