Skip to content
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

Memory leak when you try to insert a line to a large text #54

Open
doonfrs opened this issue Dec 1, 2024 · 3 comments
Open

Memory leak when you try to insert a line to a large text #54

doonfrs opened this issue Dec 1, 2024 · 3 comments
Assignees
Labels
bug Something isn't working performance

Comments

@doonfrs
Copy link

doonfrs commented Dec 1, 2024

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. set a large text to the editor
  2. for loop from 1 to 100
  3. textController.text += 'anytext';
  4. 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
@doonfrs doonfrs added the bug Something isn't working label Dec 1, 2024
@doonfrs
Copy link
Author

doonfrs commented Dec 1, 2024

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.

@MegatronKing
Copy link
Member

@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.

@doonfrs
Copy link
Author

doonfrs commented Dec 5, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance
Projects
None yet
Development

No branches or pull requests

2 participants