[Qt-interest] Memory issues with painter->drawText() (shiva sitamraju)

shiva sitamraju shivaenigma at gmail.com
Tue May 19 12:53:47 CEST 2009


Hi Martin,

Thanks very much. I added

Qt::WA_DeleteOnClose flag and the memory usage is not coming down.


Attaching the updated code.


Thanks




On Tue, May 19, 2009 at 3:30 PM, <qt-interest-request at trolltech.com> wrote:

> Send Qt-interest mailing list submissions to
>        qt-interest at trolltech.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.trolltech.com/mailman/listinfo/qt-interest
> or, via email, send a message with subject or body 'help' to
>        qt-interest-request at trolltech.com
>
> You can reach the person managing the list at
>        qt-interest-owner at trolltech.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Qt-interest digest..."
>
> Today's Topics:
>
>   1. Re: How the Qt-designer "Widget-Box" is developed. -      Can I
>      see the source code for the same! (Tiago Correia)
>   2. Memory issues with painter->drawText() (shiva sitamraju)
>   3. Doubt in qInstallMsgHandler (Ravi Krishna)
>   4. Re: Doubt in qInstallMsgHandler (Mohammed Sameer)
>
>
> ---------- Forwarded message ----------
> From: Tiago Correia <tiago at cnotinfor.pt>
> To: "qt-interest at trolltech.com" <qt-interest at trolltech.com>
> Date: Tue, 19 May 2009 09:25:34 +0100
> Subject: Re: [Qt-interest] How the Qt-designer "Widget-Box" is developed. -
> Can I see the source code for the same!
> Hi,
> The source code from QDesigner is available, in the folder
> <QT Dir>/tools/designer/src/
>
> On Tue, May 19, 2009 at 6:37 AM, Santhosh Y <santhosh at softjin.com> wrote:
>
>> Hi,
>>
>> Please find the attached file in which the Qt-Designer snapshot is shown.
>> In widget Box which is highlighted in red in the attached document,
>> "Layouts, Spacers, Buttons, Item Views" are in layout.
>>
>> How they developed this Widget Box, so that the underlying items having
>> such layout so that, each item can be expanded or collapsed.
>>
>> Please help me or suggest me where to find the code for the same.
>>
>> Is the source code for developing Qt-designer is available?
>>
>> --
>> ----------------------------------------------------
>> Y Santhosh Kumar
>> Senior Software Engineer
>> SoftJin Technologies Private Limited
>> Unit No. 102, Mobius Tower,
>> I Floor, SJR I - Park,
>> EPIP, White Field,
>> Bangalore - 560066, India
>> U : www.softjin.com
>> E : santhosh at softjin.com
>> T : +91-80-41779999
>> M : +91-9740535265
>> ----------------------------------------------------
>>
>>
>>
>> Business Disclaimer
>> ____________________________________________________________
>> This e-mail message and any files transmitted with it are intended solely
>> for  the use  of the  individual or entity  to which they  are  addressed.
>> It
>> may  contain confidential,  proprietary or legally  privileged
>>  information.
>> If  you  are  not  the  intended recipient please be advised that you have
>> received  this  message in error and any use is strictly prohibited.
>> Please
>> immediately  delete it  and all copies of it from your system, destroy any
>> hard  copies  of  it and  notify  the  sender  by return mail. You must
>> not,
>> directly or indirectly, use,  disclose,  distribute, print, or copy any
>> part of
>> this message if you are not the intended recipient.
>> ___________________________________________________________
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
>
> --
> Tiago Correia
> chief technology officer
>
> cnoti inovação & desenvolvimento – Aprendizagem enRiquecida pela Tecnologia
> www.cnotinfor.pt
> Telefone: +351 239 499 231
>
> Subscreva gratuitamente a nossa Newsletter BICA – Boletim informativo de
> Interactividade, Comunicação e Aprendizagem
>
>
>
> ---------- Forwarded message ----------
> From: shiva sitamraju <shivaenigma at gmail.com>
> To: qt-interest at trolltech.com
> Date: Tue, 19 May 2009 14:16:24 +0530
> Subject: [Qt-interest] Memory issues with painter->drawText()
> Hi everyone,
>
> Here is my issue. Whenever i call painter->drawText (with some newlines in
> the text) the resident memory usage shoots up by around 10MB. Also to add to
> the problems, the memory is not released when I close the widget.
>
> I am attaching the code to test this problem.  I create a widget with a
> pushbutton and on clicking the button I set a flag, due to which text is
> drawn in paintEvent.
>
> After the paintEvent starts painting text the resident memory (res shown in
> top) shoots up by around 10MB which is not released even after I close the
> widget. Virtual memory usage also shoots up by a large number(around 100MB)
> and is not reclaimed.
>
> I would be glad if someone can throw some insight on why this is happening.
>
> Thanks
> -Shiva
>
>
> ---------- Forwarded message ----------
> From: Ravi Krishna <ravik at softjin.com>
> To: qt-interest at trolltech.com
> Date: Tue, 19 May 2009 14:57:55 +0530
> Subject: [Qt-interest] Doubt in qInstallMsgHandler
> Hi,
> When I run my QT application I am getting the following error
> "QList: Out of Memory"
> on stdout when the message handler is not set.
>
> To catch all the fatal error messages I set qInstallMsgHandler to myMsgOut.
>
> void myMsgOut(QtMsgType type, const char *msg)
> {
>  switch (type) {
>   case QtCriticalMsg:
>       std::cout << msg << std::endl;
>       break;
>   case QtFatalMsg:
>       std::cout << msg << std::endl;
>       QMessageBox::critical(NULL, "Fatal error", msg);
>       break;
>   default:
>       std::cout << msg << std::endl;
>       break;
>   }
> }
>
> But after setting the message handler to myMsgOut, the application is
> crashing, without giving any output. I wanted to know is there any problem
> in my message handler function.
>
>
> Regards,
> Ravi krishna.M
>
>
>
> Business Disclaimer
> ____________________________________________________________
> This e-mail message and any files transmitted with it are intended solely
> for  the use  of the  individual or entity  to which they  are  addressed.
> It
> may  contain confidential,  proprietary or legally  privileged
>  information.
> If  you  are  not  the  intended recipient please be advised that you have
> received  this  message in error and any use is strictly prohibited. Please
> immediately  delete it  and all copies of it from your system, destroy any
> hard  copies  of  it and  notify  the  sender  by return mail. You must
> not,
> directly or indirectly, use,  disclose,  distribute, print, or copy any
> part of
> this message if you are not the intended recipient.
> ___________________________________________________________
>
>
>
>
>
> ---------- Forwarded message ----------
> From: Mohammed Sameer <msameer at foolab.org>
> To: qt-interest at trolltech.com
> Date: Tue, 19 May 2009 12:30:41 +0300
> Subject: Re: [Qt-interest] Doubt in qInstallMsgHandler
> On Tue, May 19, 2009 at 02:57:55PM +0530, Ravi Krishna wrote:
> > Hi,
> > When I run my QT application I am getting the following error
> > "QList: Out of Memory"
> > on stdout when the message handler is not set.
> >
> > To catch all the fatal error messages I set qInstallMsgHandler to
> myMsgOut.
> >
> > void myMsgOut(QtMsgType type, const char *msg)
> > {
> >    switch (type) {
> >     case QtCriticalMsg:
> >         std::cout << msg << std::endl;
> >         break;
> >     case QtFatalMsg:
> >         std::cout << msg << std::endl;
> >         QMessageBox::critical(NULL, "Fatal error", msg);
> >         break;
> >     default:
> >         std::cout << msg << std::endl;
> >         break;
> >     }
> > }
> >
> > But after setting the message handler to myMsgOut, the application is
> > crashing, without giving any output. I wanted to know is there any
> > problem in my message handler function.
>
> I don't know the reason for the crash but if it's an out of memory
> condition then
> I guess you should not create new widgets because it'll probably fail (No
> memory) and if it
> fails because of an out of memory condition then it might end up calling
> your handler again
> ... and so on ;-)
>
> Just my 0.02
>
>
> Cheers,
>
> --
> GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
> Debian User and Developer.
> Homepage: www.foolab.org
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/73fc4ef6/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mainwindow.cpp
Type: text/x-c++src
Size: 752 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/73fc4ef6/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 310 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/73fc4ef6/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mainwindow.h
Type: text/x-chdr
Size: 373 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/73fc4ef6/attachment-0002.bin 


More information about the Qt-interest-old mailing list