Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to detect memory leak on Symbian?
Forum Updated to NodeBB v4.3 + New Features

How to detect memory leak on Symbian?

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hungchuviet
    wrote on last edited by
    #1

    I've tested my app with Glowcode utility on windows XP SP3(Debug with ms vc++2008), no memory leak found.
    In my code, I use pointer variable and delete them after use.
    When app started,main window displayed, free phone memory reduced about 17 MB,
    With this app, when I deploy on symbian (Nokia E72,E71), Qt 4.6.2, QtMobility 1.1, if I call a test function many times, after each call, free memory on phone go down (Im using RnD Tools-PerfMon).If Call times reach about tens, the APP crash.
    Main function below:
    @#include <QtGui/QApplication>
    #include "compileroption.h"
    #include "kqxsmainwindow.h"
    #ifdef VC2008
    #include "wmainwindow.h"
    #endif
    #include <QString>
    #include <QMessageBox>
    #include <QtSql>
    QSqlDatabase g_db;
    int main(int argc, char *argv[])
    {
    // QT block
    #ifndef VC2008
    {
    QApplication a(argc, argv);
    g_db=QSqlDatabase::addDatabase("QSQLITE");
    if (!g_db.isValid())
    QMessageBox::critical(NULL,QString::fromUtf8("Lỗi"),QString::fromUtf8("Driver CSDL:")
    +g_db.lastError().text()
    );
    g_db.setDatabaseName("data.db");
    if(!g_db.open())
    {
    QMessageBox::critical(NULL,QString::fromUtf8("Lỗi"),QString::fromUtf8("Lỗi kết nối:")
    +g_db.lastError().text());
    }
    kqxsMainWindow w;
    #if (defined (Q_OS_SYMBIAN) || defined (Q_OS_LINUX))
    w.showMaximized();
    #else
    w.showMaximized();
    #endif

    return a.exec&#40;&#41;;
    }
    // end QT
    

    #else
    /*VC++ block */
    {
    QApplication a(argc, argv);
    QString s,o;
    g_db=QSqlDatabase::addDatabase("QSQLITE");
    if (!g_db.isValid())
    QMessageBox::critical(NULL,QString::fromUtf8("Lỗi"),QString::fromUtf8("Driver CSDL:")
    +g_db.lastError().text()
    );
    g_db.setDatabaseName("data.db");
    if(!g_db.open())
    {
    QMessageBox::critical(NULL,QString::fromUtf8("Lỗi"),QString::fromUtf8("Lỗi kết nối:")
    +g_db.lastError().text()
    );
    }
    WMainWindow w;
    #if (defined (Q_OS_SYMBIAN) || defined (Q_OS_LINUX))
    w.showMaximized();
    #else
    w.showMaximized();
    #endif

                return a.exec(&#41;;
        }
     // end VC++
    

    #endif
    }@
    Have any way to find and fix problem?
    Thanks you very much.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      danilocesar
      wrote on last edited by
      #2

      It doesn't need to be a proper leak (losing references to allocated pointers) to see your memory not being freed.

      On linux/maemo/meego, I would recommend you to run your code with valgrind (using memcheck and massif modules) to see exactly which part of your memory is increasing. For sure there's a equivalent tool for windows/symbian.

      <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
      Software Engineer

      1 Reply Last reply
      0
      • S Offline
        S Offline
        srikanth_trulyit
        wrote on last edited by
        #3

        Symbian way of writing the code is not like any other platforms. Memory Management is an integral part of the OS architecture. If you use resource hungry classes, make sure you reuse them rather than creating them very often. Also prefer to create using new operator rather than creating on the stack, because stack is very precious. If you run on a Symbian emulator (you will get S60 5th edition SDK from forum nokia), you can get the memory leaks and "ALLOC" errors with the memory address. After that you can use HookLogger to detect where exactly the leak has occured ( see http://wiki.forum.nokia.com/index.php/Detecting_memory_leaks_with_HookLogger about hooklogger). Qt classes on Symbian do have some memory leaks especially resource handle classes, so you can count them too for your issue.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved