Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TextArea memory leak - QML
Forum Updated to NodeBB v4.3 + New Features

TextArea memory leak - QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 5 Posters 922 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MohammadsmM Offline
    MohammadsmM Offline
    Mohammadsm
    wrote on last edited by
    #1

    Hi
    Recently, I realized that the used memory by a qml application, will increase by inputting text to a TextArea component(which is logical).
    But it won't come down by removing TextArea characters! I tried TextArea.clear(), but the used memory will not change.
    I even tried TextArea.destroy(), the component will disappear visually, but memory size is still as high as it was before TextArea deletion!

    It makes OS hang after a long type & clear.

    How should I manage the memory with TextArea?

    1 Reply Last reply
    2
    • S Offline
      S Offline
      shaan7
      wrote on last edited by
      #2

      Hey @Mohammadsm I recently saw this same problem and was very surprised. Did you eventually find something about this?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        c0ntrarian
        wrote on last edited by
        #3

        +1 Also have the same issue.

        1 Reply Last reply
        0
        • JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          How are you all measuring this memory usage? Unless you use a proper tool it won't mean a lot, not something like Windows Task Manager. Usually memory released by freeing objects is not returned to the OS, but may (hopefully) be re-used for future allocations. Unless it keeps allocating more and more memory, or runs out of memory, it is not clear there is any problem.

          S 1 Reply Last reply
          1
          • JonBJ JonB

            How are you all measuring this memory usage? Unless you use a proper tool it won't mean a lot, not something like Windows Task Manager. Usually memory released by freeing objects is not returned to the OS, but may (hopefully) be re-used for future allocations. Unless it keeps allocating more and more memory, or runs out of memory, it is not clear there is any problem.

            S Offline
            S Offline
            shaan7
            wrote on last edited by
            #5

            @JonB said in TextArea memory leak - QML:

            Unless it keeps allocating more and more memory, or runs out of memory

            This is exactly what used to happen when I had first replied on this issue. We later traced it to being specific to ANGLE. Somehow there were QSG textures that were kept in memory even if you called TextArea.clear(), and they didn't get reused. So pasting+clearing a large amount of text multiple times would eventually cause a OOM.

            However, I don't work on that project anymore so not sure if its still the case with the newer RHI framework.

            JonBJ 1 Reply Last reply
            2
            • S shaan7

              @JonB said in TextArea memory leak - QML:

              Unless it keeps allocating more and more memory, or runs out of memory

              This is exactly what used to happen when I had first replied on this issue. We later traced it to being specific to ANGLE. Somehow there were QSG textures that were kept in memory even if you called TextArea.clear(), and they didn't get reused. So pasting+clearing a large amount of text multiple times would eventually cause a OOM.

              However, I don't work on that project anymore so not sure if its still the case with the newer RHI framework.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @shaan7
              I understand for your case, and thanks for posting to clarify.
              I doubt that applies to the other/latest poster.

              1 Reply Last reply
              1
              • C Offline
                C Offline
                c0ntrarian
                wrote on last edited by c0ntrarian
                #7

                I am measuring memory usage in Windows Task Manager. Every 5 lines I add, it increases memory by ~5 MB until it halts the operation of the computer I'm debugging on. The thing is that I need TextArea to have over 10,000 lines of text at a given time because we are collecting log data from a microcontroller. Is there any other QML feature that is skinnier (like QPlainTextEdit) but callable/drag and droppable in QML directly?

                S 1 Reply Last reply
                0
                • C c0ntrarian

                  I am measuring memory usage in Windows Task Manager. Every 5 lines I add, it increases memory by ~5 MB until it halts the operation of the computer I'm debugging on. The thing is that I need TextArea to have over 10,000 lines of text at a given time because we are collecting log data from a microcontroller. Is there any other QML feature that is skinnier (like QPlainTextEdit) but callable/drag and droppable in QML directly?

                  S Offline
                  S Offline
                  shaan7
                  wrote on last edited by shaan7
                  #8

                  @c0ntrarian Two things:

                  1. Which Qt version and platform is your app on? Does the memory usage go down if you clear all the text after adding lots of it? If you're on Qt5.x with ANGLE, you can try using a different GL mode, although YMMV.

                  2. If you don't need to edit the text, this approach might help: https://www.kdab.com/handling-a-lot-of-text-in-qml/

                  1 Reply Last reply
                  0
                  • enjoysmathE Offline
                    enjoysmathE Offline
                    enjoysmath
                    wrote on last edited by
                    #9

                    I guess the QObject* hierarchy doesn't garbage collect itself after all! Suggestion: delete your pointers as usual, use QSharedPointer minimalistically where it counts.

                    https://github.com/enjoysmath
                    https://math.stackexchange.com/users/26327/exercisingmathematician

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved