Results 1 to 10 of 10

Thread: Memory Leakage problem.

  1. #1
    Join Date
    Jan 2011
    Location
    Karachi, Pakistan
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Memory Leakage problem.

    Hi guys,

    I execute the following code to make sis file for my Nokia 5800xm, but my phone got hang, and eventually i had to remove the battery to restart my phone. I think the application is not handling the memory leakage,, so please help to get out of this problem.

    Qt Code:
    1. QSystemDeviceInfo file(this);
    2. QSystemNetworkInfo file1(this);
    3. ui->progressBar->setValue(file.batteryLevel());
    4. ui->label->setText("Battery Left: " + QString::number(file.batteryLevel()));
    5. ui->label_2->setText("IMEI: " + file.imei());
    6. ui->label_3->setText("Model: " + file.model());
    7. ui->label_4->setText("Signal Strength: " + QString::number(file1.networkSignalStrength(QSystemNetworkInfo::GsmMode))+ "%");
    8. ui->label_5->setText("Stand By: " + QString::number(file.batteryLevel()*2) + "mins");
    9. ui->label_7->setText("Net Name: " + file1.networkName(QSystemNetworkInfo::GsmMode));
    10. ui->label_8->setText("Cell Id Of BS: " + file1.cellId());
    11. ui->label_9->setText("Mob Code: " + file1.currentMobileNetworkCode());
    12. ui->label_10->setText("MAC: " + file1.macAddress(QSystemNetworkInfo::GsmMode));
    To copy to clipboard, switch view to plain text mode 

    Please Give me chance to say thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Memory Leakage problem.

    There is not mem leakage in the code you posted.
    If you have memory leak, it is somewhere else in your code.
    You should really use some memory checking tool to be sure.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2011
    Location
    Karachi, Pakistan
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Memory Leakage problem.

    Thanks for Reply

    Can you please tell me the name of mem checking tools

    thanks.

  4. #4
    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: Memory Leakage problem.

    You can try Valgrind

  5. #5
    Join Date
    Jan 2011
    Location
    Karachi, Pakistan
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Memory Leakage problem.

    Thanks for reply...


    I am using Windows operating system.

    @high_flyer:

    i am using only that code, but when i try to run it in my nokia 5800 xm, my mobile goes hang. So i think memory leakage is causing the problem

    Thanks

  6. #6
    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: Memory Leakage problem.

    I am using Windows operating system.
    You may want to update your profile's OS icon, it says "Unix/X11" now

  7. The following user says thank you to stampede for this useful post:

    bilalsaeed (12th February 2011)

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Memory Leakage problem.

    So i think memory leakage is causing the problem
    Why do think that?

    Memory leaks usually can cause a crash only when the memory limit is reached and that usually takes some time.
    Show the rest of your code, my guess is that something else is causing the crash.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #8
    Join Date
    Jan 2011
    Location
    Karachi, Pakistan
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Memory Leakage problem.

    high_flyer thanks for your support,

    Here's the MainWindow.cpp file

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow){
    7.  
    8. ui->setupUi(this);
    9. ui->label->setShown(false);
    10. ui->label_2->setShown(false);
    11. ui->label_3->setShown(false);
    12. ui->label_4->setShown(false);
    13. ui->label_5->setShown(false);
    14. ui->label_6->setShown(false);
    15. ui->label_7->setShown(false);
    16. ui->label_8->setShown(false);
    17. ui->label_9->setShown(false);
    18. ui->label_10->setShown(false);
    19. ui->progressBar->setShown(false);
    20.  
    21. }
    22.  
    23. MainWindow::~MainWindow()
    24. {
    25. delete ui;
    26. }
    27.  
    28. void MainWindow::on_pushButton_clicked()
    29. {
    30. ui->label->setShown(true);
    31. ui->label_2->setShown(true);
    32. ui->label_3->setShown(true);
    33. ui->label_4->setShown(true);
    34. ui->label_5->setShown(true);
    35. ui->label_6->setShown(true);
    36. ui->label_7->setShown(true);
    37. ui->label_8->setShown(true);
    38. ui->label_9->setShown(true);
    39. ui->label_10->setShown(true);
    40. ui->progressBar->setShown(true);
    41.  
    42.  
    43. ui->progressBar->setValue(file.batteryLevel());
    44. ui->label->setText("Battery Left: " + QString::number(file.batteryLevel()));
    45. ui->label_2->setText("IMEI: " + file.imei());
    46. ui->label_3->setText("Model: " + file.model());
    47. ui->label_4->setText("Signal Strength: " + QString::number(file1.networkSignalStrength(QSystemNetworkInfo::GsmMode))+ "%");
    48. ui->label_5->setText("Stand By: " + QString::number(file.batteryLevel()*2) + "mins");
    49. ui->label_7->setText("Net Name: " + file1.networkName(QSystemNetworkInfo::GsmMode));
    50. ui->label_8->setText("Cell Id Of BS: " + file1.cellId());
    51. ui->label_9->setText("Mob Code: " + file1.currentMobileNetworkCode());
    52. ui->label_10->setText("MAC: " + file1.macAddress(QSystemNetworkInfo::GsmMode));
    53. }
    To copy to clipboard, switch view to plain text mode 

    networkinfo.pro fil

    Qt Code:
    1. QT += core gui
    2. Qt += network
    3.  
    4. TARGET = NetworkInfo
    5. TEMPLATE = app
    6.  
    7.  
    8. SOURCES += main.cpp\
    9. mainwindow.cpp
    10.  
    11. HEADERS += mainwindow.h \
    12. ../../Simulator/QtMobility/mingw/include/qmobilityglobal.h
    13.  
    14. FORMS += mainwindow.ui
    15.  
    16. CONFIG += mobility
    17. MOBILITY = systeminfo
    18.  
    19. symbian {
    20. TARGET.UID3 = 0xe07c5851
    21. TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment ReadDeviceData WriteDeviceData
    22. TARGET.EPOCSTACKSIZE = 0x14000
    23. TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    To copy to clipboard, switch view to plain text mode 

    and mainwindow.h header file

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include<QtSystemInfo/QSystemDeviceInfo>
    6. #include<QtSystemInfo/QSystemNetworkInfo>
    7. QTM_USE_NAMESPACE
    8.  
    9. namespace Ui {
    10. class MainWindow;
    11. }
    12.  
    13. class MainWindow : public QMainWindow
    14. {
    15. Q_OBJECT
    16.  
    17. public:
    18. explicit MainWindow(QWidget *parent = 0);
    19. ~MainWindow();
    20.  
    21. private:
    22. Ui::MainWindow *ui;
    23. QSystemDeviceInfo file;
    24. QSystemNetworkInfo file1;
    25.  
    26. private slots:
    27. void on_pushButton_clicked();
    28. };
    29.  
    30. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Memory Leakage problem.

    I don't see anything special that should cause a crash.
    Run this in a debugger, and see exactly on which line it crashes.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #10
    Join Date
    Jan 2011
    Location
    Karachi, Pakistan
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Memory Leakage problem.

    Thanksss higg_flyer

    It is working perfectly on debugger and doing what it is supposed to do.

    In debugger i didn't find anything that cause crash,

    Thanks for ur support

Similar Threads

  1. Virtual memory allocation problem
    By morfei in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2009, 11:30
  2. Qt Memory size problem ?
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 29th September 2008, 15:27
  3. How to solve this cc1plus: out of memory problem?
    By triperzonak in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2008, 20:20
  4. Virtual memory problem
    By Rahul in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2007, 13:29
  5. Memory Problem with SIGNALS and SLOTS
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2007, 20:39

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.