Wednesday, 11 September 2013

C# unmovable dynamically allocated arrays

C# unmovable dynamically allocated arrays

I'm making a data acquisition application in C# that calls a DLL (supplied
by DAQ card vendor) and it requires that I register my I/O buffers in that
DLL. I have a writing thread that fills the buffer with signal samples. I
see a strange behaviour that after some time the output signal becomes
noise and I suspect that's because GC has moved my buffers somewhere, so
the code in DLL has a pointer to wrong address and outputs junk to DAC.
1) How can I check if I'm right (array has been moved)?
2) If so, how to make an array unmovable? The Fixed Size Buffers page at
MSDN says I can make a buffer of a fixed size, but I need it to be
alocated dynamically (so it can be tuned before acquisition starts).

No comments:

Post a Comment