dotnet interop:
I have a C# application that calls a lower-level C++ dll to do serial
communication. (Using C++ for serial I/O is not necessary, but I was asked
to do this.)
Calls from C# to C++ functions generally look like this:
[DllImport( DLL_NAME, EntryPoint = "SetMultiplier" )]
private static extern WFGP_MSG DllSetMultiplier(
Int16 channel, UInt16 mult
);
All the calls made during a communication session use types that require no
translation in order to cross the boundary between managed and unmanaged
code. The P/Invoke calls should be just as fast as P/Invoke can be.
Everything works just fine. However, the application tends to "freeze" for
a few seconds after every few minutes of use. No data gets lost, so the
freeze is more of an annoyance than anything. However, I feel sure that it
is caused by something I am not doing correctly in the way I use unmanaged
code. My first instinct would be do assume that regular, long pauses are
caused by creating many, many objects that almost immediately go out of
scope, leaving a huge amount of work for the garbage collector. However, I
do not believe my code is creating tons of objects. Could a P/Invoke call
create a lot of temporary objects behind the scenes?
Does anyone know how you go about determining what causes regular, long