Skip to content

High memory usage #879

@mistlebee

Description

@mistlebee

Expected Behavior

I want to use the assist field like an editor with an assist function. But if the text field has a long lifetime, the memory increases a lot.
I would expect that memory usage falls, if I delete content from field.
I would also expect, that I have a similar memory usage whether I insert the content step by step or insert the whole content via copy/paste. (if I insert a lot of content via copy/paste the memory usage is very low).

Actual Behavior

I tried to profile the field. Here are my results:

  1. Memory usage is low at the beginning:
    2019-12-04 14_48_18-Java VisualVM
  2. Start writing text with stylings and create an initial heap dump (after performing garbage collection)
    2019-12-04 14_48_51-Richt Text Test
  3. Write more text with stylings
    2019-12-04 14_52_06-Richt Text Test
  4. After manual triggering of garbage collector. Memory is very high
    2019-12-04 14_52_56-Java VisualVM
  5. New heap dump in comparison with the last one
    2019-12-04 14_55_52-Java VisualVM
  6. Clear text
    2019-12-04 15_01_54-Richt Text Test
  7. Create new heap dump after garbage collection and compare to last one
    2019-12-04 15_08_06-Java VisualVM
  8. Memory usage remains high
    2019-12-04 15_08_38-Java VisualVM

With each change of text field I wand to reparse the field and update the stylings. But it seems like old stylings are never cleaned up.
I tried to use another Undomanager. Because I just need text-changes in UndoManager. I can recreate the stylings with the text parsing. But even with such a simple UndoManger the memory increases a lot.

Reproducible Demo

Here is my demo code.
richtexttest.zip

Environment info:

  • RichTextFX Version: 0.10.2
  • Operating System: Windows 10
  • Java version:1.8.121

Current Workarounds

It's possible to use dispose. But during life time of the component it is hard to find a good trigger point for recreation. Also redo/undo is lost with this workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions