I created a C++ console app using VC++ 2017. It makes a number of calls over time to retrieve data from a 3rd party COM DLL. I use COM classes like CComSafeArray and CComVariant that manage their own freeing.
Over time I observe that the memory for my App steadily increases in Task Manager after each COM call.
I have used the CRT library (https://learn.microsoft.com/en-us/visualstudio/debugger/finding-memory-leaks-using-the-crt-library?view=vs-2019) to try to detect memory leaks but it indicates I have none.
My question(s) is/are:
- Does COM in general do it's own memory management that the CRT library cannot detect but is tied to my process?
- If #1 is the case, are there tools available to detect COM memory leaks?
- If #1 is the case, is there a way to garbage collect COM memory?
Thanks for your consideration.
Edit 4-19-2019 I have found out that the COM Dll returns VARIANT's and BSTR's for function call results. I am assigning them variously to _variant_t and _bstr_t as applicable to provide automatic cleanup (theoretically). For example.
_variant_t v = GetSomeVariant();
_bstr_t b = GetSomeString();
The DLL does not use CoTaskMemAlloc but it does use SysAllocString to generate the BSTRs.