How to delete memory allocated by COM?
-
Hi, I have a COM object that actually allocate a memory and return a value to the calling function. When I call this COM object in C++, I can just delete the pointer by using delete keyword. But how can I do this in C#? How to free the memory allocated by the COM object? eg. In my COM class:
HRESULT __stdcall CTestCOM::getValues(int **arrRetVal) { int *pTmp = new int[100]; ... ... ... (*arrRetVal) = pTmp; return S_OK; }
Thanks :)
-
Hi, I have a COM object that actually allocate a memory and return a value to the calling function. When I call this COM object in C++, I can just delete the pointer by using delete keyword. But how can I do this in C#? How to free the memory allocated by the COM object? eg. In my COM class:
HRESULT __stdcall CTestCOM::getValues(int **arrRetVal) { int *pTmp = new int[100]; ... ... ... (*arrRetVal) = pTmp; return S_OK; }
Thanks :)
-
Hi, I have a COM object that actually allocate a memory and return a value to the calling function. When I call this COM object in C++, I can just delete the pointer by using delete keyword. But how can I do this in C#? How to free the memory allocated by the COM object? eg. In my COM class:
HRESULT __stdcall CTestCOM::getValues(int **arrRetVal) { int *pTmp = new int[100]; ... ... ... (*arrRetVal) = pTmp; return S_OK; }
Thanks :)
Why not add a method to the COM class that deletes a pointer that it is provided in a parameter? (Assuming here that .NET doesn't do something nasty to the pointer that makes this impossible/wrong, I'm no expert on COM Interop...)
-
Why not add a method to the COM class that deletes a pointer that it is provided in a parameter? (Assuming here that .NET doesn't do something nasty to the pointer that makes this impossible/wrong, I'm no expert on COM Interop...)