TextArea memory leak - QML
-
Hi
Recently, I realized that the used memory by a qml application, will increase by inputting text to aTextArea
component(which is logical).
But it won't come down by removingTextArea
characters! I triedTextArea.clear()
, but the used memory will not change.
I even triedTextArea.destroy()
, the component will disappear visually, but memory size is still as high as it was beforeTextArea
deletion!It makes OS hang after a long type & clear.
How should I manage the memory with
TextArea
? -
Hey @Mohammadsm I recently saw this same problem and was very surprised. Did you eventually find something about this?
-
+1 Also have the same issue.
-
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.
-
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.
@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.
-
@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.
-
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?
-
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?
@c0ntrarian Two things:
-
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.
-
If you don't need to edit the text, this approach might help: https://www.kdab.com/handling-a-lot-of-text-in-qml/
-
-
I guess the QObject* hierarchy doesn't garbage collect itself after all! Suggestion: delete your pointers as usual, use QSharedPointer minimalistically where it counts.