I have a program that is used to communicate with hardware through rs232. This software is used to display the data stream that is pushing the rs232 from the hardware as fast as it can be. The problem that I am facing is that over time, the private memory assigned to the program explodes and the program crashes very quickly. If I disconnect the equipment from sending data for about 2 minutes, then the software can clear the memory, but only if I paused the data stream.
I am using the DataReceived event from SerialPort and it seems to be a problem because it will cause a memory burst even if the DataReceived function does nothing inside. The only thing I can think of is that every time this event occurs, it creates a new thread to start, and it happens so fast that the computer does not have time to start the GC during data entry.
Is there a more efficient way to output data from a SerialPort object? Do I only care about the line when I get "NewLine"?
Thank,
John vickers
# , , , , .
?
state Init recv(); $len = length($DATA_PACKET); if("$len > 0") { log($DATA_PACKET, Debug); } end state
- , , .
DataReceived . , . - :
while (this.serialPort.IsOpen) { int b = this.serialPort.ReadByte(); if (b != -1) { // data is good here } }
, , - , .
, . SerialPort threadpool DataReceived. , TP . , .
, , , , , . Handshake, TP, .
Debug + Windows + Threads. , , . DataReceived, , , . , , , .
, DataReceived , , Control.Invoke(). , . Handshake . , . ErrorReceived btw, , , .
TP, . , 250 . .
.
DataReceived.
USB 3G-, . , DataReceived. - .
, 10 . .
Read (...) . , , , .
Source: https://habr.com/ru/post/1776547/More articles:CSS3 support trends (or: how much market will I lose if I don't use flash?) - flashI need a good Python web development framework - pythonXmlSerializer + Polymorphism - inheritanceЯ пытаюсь выбрать структуру для продукта, который я собираюсь построить, и до сих пор я склоняюсь к Нагаре... Любые мысли? - javaHsqldb event log internal configuration - java@PostConstruct method called all the time in the service of Jersey - jerseySQL How to get all retries within a specific time period - sqlUnable to change server type in SQL Management Studio 2008 - sql-serverHow to wake up a stream after receiving 2 packets - c ++Change asp based image source: Choosing DropDownList - javascriptAll Articles