G
Guest
We have found a memory leak when using a COM library with a C# application.
The leak appears only if the C# application is compiled with the /optimize
flag. It goes away when the C# application is compiled with the /debug flag.
The COM library is coded to fire asynchronous events, which are handled by
the C# application. It is in the firing and handling of these events that
the leak occurs.
Why does the optimized application leak while the debug application does
not?
Is there a fix available?
Is there another way to do asynchronous event handling that will circumvent
this problem?
Attached is a small test case that recreates the problem. The only code of
real interest in the COM library is the event firing code. If the problem
that we see is in the COM library, it would have to be in this piece of code.
However, this code is more or less the output of a wizard, it is pretty
standard stuff. The C# application is also trivial, with the only item of
any real interest being the event handler. Once again, the code has been
pared down to the point of being trivial. Any insights into asynchronous
event handling through an interop assembly is appreciated.
Thanks,
Giovanni Boschi
Sonic Software Corporation
The leak appears only if the C# application is compiled with the /optimize
flag. It goes away when the C# application is compiled with the /debug flag.
The COM library is coded to fire asynchronous events, which are handled by
the C# application. It is in the firing and handling of these events that
the leak occurs.
Why does the optimized application leak while the debug application does
not?
Is there a fix available?
Is there another way to do asynchronous event handling that will circumvent
this problem?
Attached is a small test case that recreates the problem. The only code of
real interest in the COM library is the event firing code. If the problem
that we see is in the COM library, it would have to be in this piece of code.
However, this code is more or less the output of a wizard, it is pretty
standard stuff. The C# application is also trivial, with the only item of
any real interest being the event handler. Once again, the code has been
pared down to the point of being trivial. Any insights into asynchronous
event handling through an interop assembly is appreciated.
Thanks,
Giovanni Boschi
Sonic Software Corporation