-
Notifications
You must be signed in to change notification settings - Fork 236
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
Question: what is the best practice for frequently changed text? #1203
Comments
Ideally you would like to only append the text to outputTextArea that was appended to the log file and not the whole log file every time. outputTextArea.appendText( newLogLines );
int excessLines = outputTextArea.getParagraphs().size() - maxLines;
if ( excessLines > 0 ) outputTextArea.deleteText( 0, 0, excessLines, 0 ); |
@Jugen Thanks for the reply. The another reason why I replace the whole text is that, there maybe several log files. Everytime the users can see only one of these files, but they may switch between these files frequently. And it seems the memory usage of the So in your opintion, what should I do? Maintain only one |
By what you've described I would just maintain one. The memory usage may come down if instead of replacing everything for the current log being viewed you rather use the mechanism I described above to update the text area. |
It seems to be ? I tried with an 8MB text file and the memory used was 200MB. However it does feel a bit excessive though doesn't it ? I also tried the same 8MB text file using an ordinary TextArea and that used a whopping 1GB !!! Still it seems strange, I wonder why Paragraph and ReadOnlyStyledDocument seem to need so much memory ? |
I'm working on a log text displayer: a worker thread frequently appends new log text to a file, and the displayer should display the latest log text ASAP.
For now, every time the displayer detect a change occured, it will read the log file and replace the whole text by using the
replaceText
method. The code is like this:However, if the log changes too frequently, the memory usage will be extremely high, and the scene refresh pretty slow.
The reason that I'm using the
replaceText
method is that I don't want the log text too big, so I'm maintaining a fix-size local String cache, to append new text and remove old text. So every time, I replace the whole text.So I'm asking for help to deal with this situation. Is this
RichTextFX
suitable for frequently changed text? If so, what is the proper way?The text was updated successfully, but these errors were encountered: