SerialPortStream is an independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability. Default branch is 2.x and now has support for Mono with help of a C library.
Microsoft Public License
624
stars
197
forks
source link
Reduce memory allocations created by List<WaitHandle>.ToArray() in OverlappedIoThreadMainLoop() #57
In my usage scenario, I talk to a serial device quite often. Every 15-20 ms I send a short message and then receive a similar short message. While profiling my solution I noticed that about 11.000 bytes/sec were allocated from a single location in your library.
This PR adapts the existing OverlappedIoThreadMainLoop() to reuse pre-allocated WaitHandle[] instead of allocating a WaitHandle[] every loop.
In my usage scenario, I talk to a serial device quite often. Every 15-20 ms I send a short message and then receive a similar short message. While profiling my solution I noticed that about 11.000 bytes/sec were allocated from a single location in your library.
This PR adapts the existing
OverlappedIoThreadMainLoop()
to reuse pre-allocatedWaitHandle[]
instead of allocating aWaitHandle[]
every loop.