Memory leak when you try to insert a line to a large text
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- set a large text to the editor
- for loop from 1 to 100
- textController.text += 'anytext';
- the memory will increase on each loop and it will not released.
Expected behavior insert a new line without the need to read the text ( get/set ) with text+= because the text property is CPU and memory-heavy. I expect a method like insertLine, insertText
Device:
- OS: windows
- Version 0.6.0
I fixed it by using the following approach:
_logController.moveCursorToPageEnd();
_logController.replaceSelection('\n$url : ');
the memory is not going up anymore, but I still believe something like insertText will be helpful.
@doonfrs I think it may be a cache issue. Since Flutter's paragraph is very expensive, the editor will cache the result and will not release it until the editor is destroyed.
@MegatronKing Thank you for your reply, Yes, I think we have two issues: 1 - Memory leak, the editor never releases the memory used in the text get method, if I have 50 MB of text, and I call text 10 times, I will end up with 50X10 of data in the memory, my app reaches 32 GB. 2 - I found that replaceSelection is a good alternative.