Skip to content

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

Open

Description

@doonfrs

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

Activity

  1. added
    bug
    on Dec 1, 2024
  2. doonfrs commented on Dec 1, 2024

    @doonfrs
    Author

    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.

  3. MegatronKing commented on Dec 5, 2024

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

  4. doonfrs commented on Dec 5, 2024

    @doonfrs
    Author

    @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

Metadata

Metadata

Assignees

Labels

bugperformance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions