PDA

View Full Version : QTextEdit memory leak : is this a bug?



Wing_Zero
24th August 2010, 13:22
Hi at all,
the issue i'm having with a simple program, is as simple as terrifying.

My app is a dialog with 6 QTextEdit form.
Every time a push a button i first clear (QTextEdit::clear() ) all the forms and then i set up the string (QTextEdit::setText("foo")).

Every time one of these 2 operations it is execuded the memory amount increases without never decrease.(also if I do online the Clear method).

This is definietly a memory leak, but that' certinly not my fault.

How I'm wrong? It is this the way that QTextEdit is supposed to work?

Googling a little bit I've found this:

http://lists.trolltech.com/qt-interest/2001-10/thread01084-0.html

That's exactly my issue, but no one replies with a solution.

Thanks in advance to anyone who will try to help me :)
And, as usual, sorry for my bad english.

Wing

Ginsengelf
24th August 2010, 15:40
Hi, are you sure it's not the UndoRedo function? Set

setUndoRedoEnabled(false) for the QTextEdit objects and try again.

Ginsengelf

Wing_Zero
25th August 2010, 02:13
Thanks for the answer.
I Think that this was the right solution to my problem... but wei i setted undeRedo false for all of my QTextEdit nothing's changed. It do the same thing. A bad memory leak.

lsvichet
30th May 2011, 21:35
Hi all,
I have this problem too. :crying:

ChrisW67
31st May 2011, 00:02
Congratulations ;)

What Qt version? Compiler? What have you tried? What are you doing exactly?

Post a small, compilable example that demonstrates the problem. We have yet to see any code and referenced mailing list thread is talking about Qt 3.0.0.

lsvichet
31st May 2011, 10:30
For me, i used Qt 4.7.0 32 bits on Windows 7 64 bits. Here is an example:


#include <QApplication>
#include <Qt/qtextedit.h>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QTextEdit *text=new QTextEdit;
text->resize(400,400);
text->setUndoRedoEnabled(false);
text->show();

return app.exec();
}

i) When i compile the code, i see in windows task manager that the memory used (by the exe result from this code ) is 12,700 K
ii) i copy a large text from notepad and past into textedit field, the memory used become : 13,500 K
iii) I move the cursor back/forward inside the text by arrow key, the memory used increased to : 16,100 K. I wait for a minute and it still 16,100 K.
iv) i delete the text that i just past from textedit field, the memory used is still 14,000 K. I wait for many minutes and it is still 14, 000 K.
v) if i continue past/delete manay time the memory used will increase more and more like: to 24, 000 K and it can be bigger than that.

MarekR22
31st May 2011, 11:04
Releasing memory in program doesn't mean that system will regain this memory! Most of compilers (not only C++) moves released memory to a pool for future reuse to improve performance.
So you can't relay on system information about application memory consumption. You have to have some better proof of memory leak!

FelixB
31st May 2011, 11:11
btw, as long as you don't delete your QTextEdit you're creating a memory leak by yourself ;)

stampede
31st May 2011, 14:21
if i continue past/delete manay time the memory used will increase more and more like: to 24, 000 K and it can be bigger than that.
Can you crash the app this way, just by paste & delete text in QTextEdit ? ( sorry, I don't have the time to test it :) )