Closed haakoo closed 9 years ago
The circular stream is a producer / consumer that reuses the same buffer over and over again, instead of, say, an "infinite" length queue. This is to prevent excessive memory allocations. Your problem is most likely that the consumer side is slower than the producer (for instance, the UI is slower than the device producing the packets).
You can implement a producer/consumer pattern with a regular queue instead of the circular buffer to avoid the overflow errors, but it would mitigate the symptom rather than attack the root cause (the cosumer being slower than the producer).
I've created an ugly hack where I reset/empty the buffer on internal overflow, which avoids the crash. Not pretty, and we will loose packets.
We have a problem where we quite often get InternalBufferOverflowException on Write to the BlockingCircularStream. I'm not sure the present way of handling overflow is good. Wouldn't it be better to discard old data, and by doing that drop messages, than to crash?
I'll increase the size of the buffer, but that might not solve the problem completely.
Any other ideas for how to mitigate the problem?