×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    22

    Qt application memory leak is not shown in emulator

    Hello, guys.

    I have some simple question.
    I've built simple "Hello, World" like example application with Qt 4.6.3 in Carbide.C++ 2.6.0 (I upgraded it from 2.3 - "Help"->"Check for upfates", etc.).

    I try to add memory leaks intentionally, but I don't see any ALLOC error messages when I close the application in Symbian emulator.
    I've tried this with 3rd FP1/FP2, 5th emulators - same result.

    If I add memory leaks in native Symbian C++ application code, I can see ALLOC message when I exit the app.
    It makes me crazy - I don't understand what's going on.

    I understand that Qt memory management differs from regular Symbian C++ approach, QObject tree of child objects, etc., but here I want to add memory leak in a simple way.
    For example:

    In main.cpp
    Code:
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        
        QLabel* pLabel = new QLabel;
        pLabel->setText(QString("blblblb"));
      
        QString* pString = new QString(1024, '.');
        pString = new QString(1024, '.');
        pString = NULL;
        
        QLabel* plabel = new QLabel("<h2><i>Hello</i><font color=red> World!</font></h2>");
        plabel->showMaximized();
        
        return a.exec();
    }
    or in QMainWindow based class:
    Code:
    QtNetworkTest::QtNetworkTest(QWidget *parent)
        : QMainWindow(parent)
    {
    	ui.setupUi(this);
    	QLineEdit* pNewEdit = new QLineEdit("blabla");
    	pNewEdit = new QLineEdit("blabla");
    	
    	HBufC* pBuf = HBufC::NewL(100);
    	HBufC* pBuf1 = HBufC::New(1000);
    	char* pch = new char[200];
    	
                         // class member creation
    	ipNewLineEdit = new QLineEdit("nadadadad");
    	pNewEdit->setText(QString("test123"));
    	int* pInt = new int[100];
    	
    }
    If I write some code, like divide_by_zero - the application is closed with KERN-EXEC 3 - that's ok, but ALLOC message I cannot see

    Any advise?

    Thanks a lot!

    Genady.

  2. #2
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    12

    Re: Qt application memory leak is not shown in emulator

    Qt disables the ALLOC panic, as it doesn't give any meaningful information for a Qt application. That is why you do not see this panic.

    The ALLOC panic assumes that all allocated memory is deallocated by the time the application objects are deleted and the event loop exits, if not it panics. This assumption is not valid when global static objects are used and they own heap allocated memory which would be freed when the global statics are destroyed on app exit. Global static destruction happens too late for the ALLOC panic. Since Qt uses global statics widely, the ALLOC panic is inappropriate.

    Instead, QtCore.dll attempts to print a count of the numbers of heap cells and handles still allocated after all Qt related global statics have been destroyed. Look for messages like the following in your debug output:

    C:\sys\bin\MyQtApp.exe exiting with 87 allocated cells, 20 handles

    You will probably see that some heap cells and some handles are still allocated at app exit. A good way to use this information is to compare it for repeated runs of a use case in your application. For example if the figures are the same when you run your use case 2 or 10 times, your use case will not be leaking memory.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    22

    Re: Qt application memory leak is not shown in emulator

    Hello.
    Thanks for the explanation!

    I looked into emulator output - nothing valuable.

    After the application start:

    6651.485 CSysApLightsController::HandleActiveEvent
    6651.485 CSysApLightsController::SetLightsOnL: aBlinking=0, iGripOpen=1, iFlipOpen=0
    6651.490 CSysApLightsController::ReportUserActivity
    6651.490 CSysApLightsController::SetLightsOnL - LIGHTS ON
    6651.510 CNspsWsPlugin::Command( aOpcode:5
    6656.540 25020310:CMMFDevSoundAdaptation::CBody::SetPrioritySettings(const TMMFPrioritySettings &)>ENTR
    6656.540 25020310:CMMFDevSoundAdaptation::CBody::SetPrioritySettings(const TMMFPrioritySettings &)>EXIT
    6656.540 25020310:CMMFDevSoundAdaptation::CBody::MaxVolume()>ENTR
    6656.545 25020310:CMMFDevSoundAdaptation::CBody::MaxVolume()>ENTR
    6656.545 25020310:CMMFDevSoundAdaptation::CBody::SetDeviceVolume(int)>ENTR
    6656.545 25020310:CMMFDevSoundAdaptation::CBody::SetDeviceVolume(int)>EXIT
    6656.545 25020310:CMMFDevSoundAdaptation::CBody::PlayToneSequenceL(const TDesC8 &)>ENTR
    6656.860 Thread QtNetworkTest.exe::Main created @ 0xad7a48 - Win32 Thread ID 0x8b8
    6656.885 Thread QtNetworkTest.exe::Local-00b1c4c0 created @ 0xb1c780 - Win32 Thread ID 0xb88
    6656.955 P.AppUi.WSEvent.Type:21
    6656.970 FontProvider: Category=1, TextPane Height=8; mapped request=6; asked typeface=Series 60 Sans; given typeface=Series 60 Sans, actual range=7(a,d,exa,exd=5 1 1 0)
    6656.985 RAknUiServer::ConnectAknServer(), handle 0, Main
    6656.985 RAknUiServer::ConnectAknServer() end
    6656.995 FontProvider: Category=1, TextPane Height=24; mapped request=21; asked typeface=Series 60 Sans; given typeface=Series 60 Sans, actual range=24(a,d,exa,exd=16 5 4 -1)
    6657.030 P.AppUi.WSEvent.Type:14
    6657.040 P.AppUi.WSEvent.Type:14
    6657.055 P.AppUi.WSEvent.Type:14
    6657.055 P.AppUi.WSEvent.Type:14
    6657.130 Skipping sanity checking font file "Z:\resource\Fonts\heiseigoths60.ttf", because it is on the Z drive
    6657.135 Skipping sanity checking font file "Z:\resource\Fonts\s60sc.ccc", because it is on the Z drive
    6657.145 Skipping sanity checking font file "Z:\resource\Fonts\s60snr.ttf", because it is on the Z drive
    6657.150 Skipping sanity checking font file "Z:\resource\Fonts\s60ssb.ttf", because it is on the Z drive
    6657.155 Skipping sanity checking font file "Z:\resource\Fonts\s60tchk.ccc", because it is on the Z drive
    6657.160 Skipping sanity checking font file "Z:\resource\Fonts\s60tsb.ttf", because it is on the Z drive
    6657.165 Skipping sanity checking font file "Z:\resource\Fonts\s60zdigi.ttf", because it is on the Z drive
    6657.205 FontProvider: Category=1, TextPane Height=20; mapped request=17; asked typeface=Series 60 Sans; given typeface=Series 60 Sans, actual range=19(a,d,exa,exd=12 5 4 -2)
    6657.220 FontProvider: Category=3, TextPane Height=24; mapped request=21; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=24(a,d,exa,exd=16 5 4 -1)
    6657.225 FontProvider: Category=3, TextPane Height=18; mapped request=15; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=18(a,d,exa,exd=11 4 4 -1)
    6657.230 [AccFW: ACCFWUINOTIFIER] CAccFwUiDialogNotifier::Info() - enter
    6657.230 [AccFW: ACCFWUINOTIFIER] CAccFwUiDialogNotifier::Info() - return void
    6657.230 [AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::Info() - enter
    6657.235 [AccFW: ACCFWUINOTIFIER] CAccFwUiNoteNotifier::Info() - return
    6657.275 FontProvider: Category=3, TextPane Height=21; mapped request=18; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=20(a,d,exa,exd=14 4 3 -1)
    6657.280 FontProvider: Category=3, TextPane Height=17; mapped request=14; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=15(a,d,exa,exd=10 4 3 -2)
    6657.280 FontProvider: Category=3, TextPane Height=19; mapped request=16; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=19(a,d,exa,exd=11 5 5 -2)
    6657.295 FontProvider: Category=3, TextPane Height=27; mapped request=25; asked typeface=Series 60 Sans TitleSmBd; given typeface=Series 60 Sans TitleSmBd, actual range=27(a,d,exa,exd=20 5 3 -1)
    6657.365 FontProvider: Category=1, TextPane Height=14; mapped request=12; asked typeface=Series 60 Sans; given typeface=Series 60 Sans, actual range=15(a,d,exa,exd=9 3 3 0)
    6673.880 CSysApLightsController::HandleInactiveEvent
    6673.880 CSysApLightsController::SetLightsOffL: iBatteryEmpty=0, iLightsCurrentlyOn=1, iForcedLightsOn=0
    6673.895 CNspsWsPlugin::Command( aOpcode:4

    Atfer the application exit:

    6749.315 25020310:CMMFDevSoundAdaptation::CBody::SetPrioritySettings(const TMMFPrioritySettings &)>ENTR
    6749.315 25020310:CMMFDevSoundAdaptation::CBody::SetPrioritySettings(const TMMFPrioritySettings &)>EXIT
    6749.315 25020310:CMMFDevSoundAdaptation::CBody::MaxVolume()>ENTR
    6749.315 25020310:CMMFDevSoundAdaptation::CBody::MaxVolume()>ENTR
    6749.315 25020310:CMMFDevSoundAdaptation::CBody::SetDeviceVolume(int)>ENTR
    6749.320 25020310:CMMFDevSoundAdaptation::CBody::SetDeviceVolume(int)>EXIT
    6749.320 25020310:CMMFDevSoundAdaptation::CBody::PlayToneSequenceL(const TDesC8 &)>ENTR
    6749.390 P.AppUi.WSEvent.Type:14
    6749.395 P.AppUi.WSEvent.Type:21
    6749.450 TeUtl: ECN.HandleCallBack.<
    6749.450 TeUtl: ECN.DoHandleCallBack.<
    6749.450 TeUtl: ECN.DoHandleCallBack.>
    6749.450 TeUtl: ECN.HandleCallBack.>
    6749.455 TeUtl: ECN.HandleCallBack.<
    6749.455 TeUtl: ECN.DoHandleCallBack.<
    6749.455 TeUtl: ECN.DoHandleCallBack.>
    6749.455 TeUtl: ECN.HandleCallBack.>
    6749.530 CDRMClock::TimeChanged
    6749.535 CDRMClock::TimeChanged ok
    6749.540 CDRMClock::TimeChanged
    6749.555 CDRMClock::TimeChanged ok

    May be I should look somewhere else?

    Thank you!

    Genady.

  4. #4
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    12

    Re: Qt application memory leak is not shown in emulator

    Quote Originally Posted by bgenady View Post
    May be I should look somewhere else?
    Debug output is the right place to look, the message should be printed as the application is exiting. Try looking just a bit further up after application exit, as there can be quite a lot of debug output printed.

Similar Threads

  1. Replies: 7
    Last Post: 2010-02-02, 09:59
  2. tool to find memory leak for emulator
    By ishan.malviya in forum Symbian
    Replies: 5
    Last Post: 2008-09-10, 19:41
  3. Memory leak in emulator using libcrypto
    By Sorcery-ltd in forum Tools and SDK Feedback (Closed)
    Replies: 3
    Last Post: 2007-06-02, 10:50
  4. memory leak on emulator = memory leak on device
    By manmli in forum Mobile Java General
    Replies: 2
    Last Post: 2006-08-05, 19:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×