Solved Qt's QTextEdit has big memory leak problem
-
I change the QTextEdit to QPlainTextEdit .
My test :
bootup : 56MB ( it is too big I think , just so little a demo )setdata : 279 MB
cleardata: 180MB ( does not release all )setdata : 279 MB
cleardata: 180MBsetdata : 279 MB
setdata : 459 MB
cleardata: 262MB ( does not release all )If it can release cleanly , I would appreciate it .
-
I compile and run the Application.exe of Qt's example which is a simple text edit, repeat paste text into it , make the memory consumption roket up , then delete them all , the phenomenon recurrs.
-
@cyberpunker And how do you measure?
-
Xfce's task manager
-
quoting @Christian-Ehrlicher:
With a proper tool like e.g. valgrind or heaptrack, not with top nor Task Manager!
Regards
-
any problem with xfce's task manager ?
I run valgrind in qtcreator, it can't endup ,so I give up.
-
@cyberpunker said in Qt's QTextEdit has big memory leak problem:
any problem with xfce's task manager ?
The OS does not display all freed memory instantly. Only if new memory requirements appear, the freed memory is taken into account.
So what you see in task manager is only updated if required.
-
@cyberpunker said in Qt's QTextEdit has big memory leak problem:
setdata : 279 MB
cleardata: 180MB ( does not release all )
setdata : 279 MB
cleardata: 180MBThis part at least confirms my suggestion that your program will be able to re-use memory which gets freed, does it not?
-
Hi,
Since it's a log and you likely are going to scroll through it, you might want to consider using a QListView and have one row per line of your log.
-
Hi
When using TextEdit as log viewer , its often a good idea to
use
setUndoRedoEnabled(false);
so it doesn't keep a copy around to be able to undo text changes.Oh. sorry. already mentioned.