-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Mitigated Serial Monitor resource exhaustion #2491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e sends a lot of data Fixes arduino#2233
len = getDocument().getLength(); | ||
if (len > maxChars) { | ||
int n = len - maxChars; | ||
System.out.println("trimDocument: remove " + n + " chars"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Oh, opps, yeah, I missed that print before committing the code. |
It looks like if I unckeck autoscrolling, it stops working. Right after re-enabling it, it says (with that removed println) it has removed all the accumulated extra chars. Something like
|
Yup, work remains to be done for turning off autoscroll. I wrote a more detailed explanation here: |
If you or anyone else reading works on this, please understand that you absolutely must not trim the document while autoscroll is turned off. Doing so ruins the user experience. But you can discard incoming data (before it's added to the document), hopefully after some reasonable threshold that won't be hit for slower data rates and only brief disable of autoscroll. |
Before this patch every byte received from Serial invokes a String allocation, not really efficient. Moreover a InputStreamReader is chained on the serial InputStream to correctly convert bytes into UTF-8 characters.
When the "autoscroll" checkbox is deselected the buffer may continue to grow up to twice of the maximum size. This is a compromise to ensure a better user experience and, at the same time, reduce the chance to lose data and get "holes" in the serial stream. See arduino#2491
I've updated the pull request:
|
Fixes #2233
Tested on a Dual-core 1.8Ghz Linux 64bit system with 4GB of RAM: the Serial Monitor performance are dramatically improved.
/cc @PaulStoffregen @willie68 @xxxajk @ffissore