Kathleen Beaumont
2003-10-17 13:44:51 UTC
I'm reposting this question because we never got it answered in our
original post.
We have a COM object that allocates memory for a BSTR. The client
accepts the return value from the COM object into a WideString variable.
We discovered (using AQTime 3) that this was causing a memory leak, and
we now understand why. Our solution is to change the code in the COM
object and in the client so that the client passes in a WideString (or
PCHAR) argument by reference, the COM object fills it, and thus the
memory management all takes place in the client.
THE QUESTION IS:
Is there any way for Delphi to free the memory allocated by a COM object?
We could manage it with a C++ Builder client (using a BSTR to accept the
return value from the COM, and invoking ::SysFreeString to deallocate
the memory). But if such an arrangement is possible using Delphi, we
couldn't make it happen.
Just want to know.
Thanks,
Kathleen
original post.
We have a COM object that allocates memory for a BSTR. The client
accepts the return value from the COM object into a WideString variable.
We discovered (using AQTime 3) that this was causing a memory leak, and
we now understand why. Our solution is to change the code in the COM
object and in the client so that the client passes in a WideString (or
PCHAR) argument by reference, the COM object fills it, and thus the
memory management all takes place in the client.
THE QUESTION IS:
Is there any way for Delphi to free the memory allocated by a COM object?
We could manage it with a C++ Builder client (using a BSTR to accept the
return value from the COM, and invoking ::SysFreeString to deallocate
the memory). But if such an arrangement is possible using Delphi, we
couldn't make it happen.
Just want to know.
Thanks,
Kathleen