Results 1 to 9 of 9

Thread: QTextEdit memory leak : is this a bug?

  1. #1
    Join Date
    Mar 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default QTextEdit memory leak : is this a bug?

    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-intere...ad01084-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

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    518
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit memory leak : is this a bug?

    Hi, are you sure it's not the UndoRedo function? Set
    Qt Code:
    1. setUndoRedoEnabled(false)
    To copy to clipboard, switch view to plain text mode 
    for the QTextEdit objects and try again.

    Ginsengelf

  3. #3
    Join Date
    Mar 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: QTextEdit memory leak : is this a bug?

    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.

  4. #4
    Join Date
    May 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit memory leak : is this a bug?

    Hi all,
    I have this problem too.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTextEdit memory leak : is this a bug?

    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.

  6. #6
    Join Date
    May 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit memory leak : is this a bug?

    For me, i used Qt 4.7.0 32 bits on Windows 7 64 bits. Here is an example:

    Qt Code:
    1. #include <QApplication>
    2. #include <Qt/qtextedit.h>
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7. QTextEdit *text=new QTextEdit;
    8. text->resize(400,400);
    9. text->setUndoRedoEnabled(false);
    10. text->show();
    11.  
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    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.

  7. #7
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextEdit memory leak : is this a bug?

    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!

  8. #8
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit memory leak : is this a bug?

    btw, as long as you don't delete your QTextEdit you're creating a memory leak by yourself

  9. #9
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTextEdit memory leak : is this a bug?

    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 )

Similar Threads

  1. Qt dll + memory leak
    By Fastman in forum Qt Programming
    Replies: 3
    Last Post: 2nd August 2009, 13:28
  2. Memory leak of Qt?
    By Sheng in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2009, 23:32
  3. memory leak
    By mattia in forum Newbie
    Replies: 18
    Last Post: 16th January 2008, 10:22
  4. Memory leak?
    By Enygma in forum Qt Programming
    Replies: 10
    Last Post: 4th September 2007, 16:24
  5. Memory leak
    By zlatko in forum Qt Programming
    Replies: 8
    Last Post: 28th March 2006, 19:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.