termdash
termdash copied to clipboard
Circular / Ring Buffer for Text Widget
I've started using this for a quick internal project, with one of features being log files monitored and displayed in real-time while other stats are displayed.
While this is working, one issue we've of course hit is when verbose logs are monitored that the size of the text buffer keeps increasing and of course leads to high memory usage and performance degradation.
A possible fix to this is to implement a simple ring buffer, where the Text content
has an (optional) maximum it can grow to. During the Write
call it could then pop content off the top of the buffer as required so that it never grows further than the maximum content.
I've added this as a basic proof of concept internally, but wanted to confirm if this would be the best approach (or if I'm missing something obvious!) before submitting any pull request.
Hi @timbutler, you raise a good point about the memory usage when the content
of the Text
widget just grows.
Adding an optional circular buffer sounds like a great idea. Such PR would be a great addition to the Text
widget, if you're willing to submit it. Please see CONTRIBUTING.md for additional instructions (e.g. which branch to fork from).
Don't hesitate to let me know if you have any questions or would like to discuss the API change upfront.
Thanks for the rapid feedback @mum4k! I'll tidy my quick edits and submit a PR in the next few days for further feedback.
Sounds great, looking forward to it @timbutler.