Object creation safety / memory leaks detection on Symbian



  • Hi,

    I have few questions related to memory handling:

    Object creation
    Comparing to Symbian it looks that on Qt we do not care too much about safe object creation and allocation failure, is that right? I can see on many examples in which objects are creating in a row with no use of smart-pointers or QObject hierarchy immediatelly, e.g. here:
    Code:

    @...
    QSpinBox* spinBox = new QSpinBox;
    QSlider* slider = new QSlider(Qt::Horizontal);
    ...@

    Sorry for asking, but developing for Symbian for years I am trained to care about everything with CleanupStack, but here seems we simply do not care about this, even we should...

    Memory leaks
    What I'm missing is the memory allocation error on application exit - which prevents many leaks during the development - I can understand reasons why it is not working, but still this worries me little as it might lead to lower software quality in some way...

    Or you have any tips how to deal with it?
    BR
    STeN



  • Hi,

    Thanks for invitation and answer... I started, well after almost 7 years of doing almost nothing then Symbian C++, moving to Qt and Qt/Symbian C++ hybrid development... Hope the Qt will be stable for some time since there were so many changes in Symbian resulted in finally in SF closing that I am wondering that there are still companies developing for it:))

    I will probably have more questions in upcoming hours, days, weeks...

    BR
    STeN



  • Qt is designed to be much simpler so it does all the nitty gritty for you. Maybe when QtMobility is stable, you'll be able to move to pure Qt rather than hybrid.

    Re: SF closing. SF wasn't for Symbian development by the way. It was just a non-profit org for Symbian support/preaching. Nokia is taking that area over now.


  • Moderators

    Hi stenlik, welcome aboard!

    The code you give as an example is indeed most likely broken with regard to memory management. Most likely since somebody might actually delete spinBox and slider manually at the right point.

    To detect memory leaks I usually run my application in valgrind on Linux (in the simulator). This works fine for me since I do not need to touch the native Symbian APIs.

    I have never been a huge fan for the memory leak reporting at the end of an application. It does little to help memory usage of the application. E.g. if I take 100k of memory every second the UI is up and clean that when I tear down the UI the end-of-application leak report will be fine, but I still have a huge resource problem. Real memory management tools (e.g. valgrind with massif) will help with this kind of issue.



  • Hi,

    [quote author="xsacha" date="1291541218"]Qt is designed to be much simpler so it does all the nitty gritty for you. Maybe when QtMobility is stable, you'll be able to move to pure Qt rather than hybrid.
    [/quote]

    I do not think the QtMobility can cover all Symbian OS APIs - it does not make sense to duplicate everything, isn't it? There are too many APIs, that I think only a portion, which most pepple are using in some 'starndard' way will be available, is that right? The same situation is on Windows/Mac, where the Qt is running - you cannot absorb all functionality and be still cross-platform and cross-version compatible.

    I agree that Qt simplifies many (especially UI - it not only simplifies AVKON, but hope makes it also more modern and more close to what Android and iPhone offer) issues, but sometimes we need more level of control then e.g. only boolean value as the function result.

    BR
    STeN



  • In Symbian^4^ they had planned to move entirely to Qt. That is, no Avkon at all. Although Symbian^4^ has been cancelled in favour of a continually evolving Symbian^3^, I think the same APIs will become available.



  • Hi,

    another note:
    [quote author="xsacha" date="1291541218"]
    Re: SF closing. SF wasn't for Symbian development by the way. It was just a non-profit org for Symbian support/preaching. Nokia is taking that area over now.[/quote]

    There are other points of view:

    1/ There was a community around Symbian Foundation, which will be lost
    2/ There was a huge number of good forum discussions, articles, etc. - all well structured
    3/ There was bug tracing, source code browsing, etc.
    4/ I do not remember any information when the SF was established that it is planned to be close at end of 2010, so what kind of signals it gives to people, like our customers, etc. - only the one, that there is some uncertainty...
    5/ Simply there was a single contact point towards OS, which was very good...

    BTW - I did not have time to study - but what are the plans for Qt+Symbian C++ future? Will it be done in a way, that Symbian will be developed independently on Qt, e.g. new APIs/functionality will be available first on Symbian OS and later absorbed by Qt or there is other model for it?

    BR
    STeN



  • Hi,

    [quote author="xsacha" date="1291542748"]In Symbian^4^ they had planned to move entirely to Qt. That is, no Avkon at all. Although Symbian^4^ has been cancelled in favour of a continually evolving Symbian^3^, I think the same APIs will become available.[/quote]

    I am aware of it, that's why I'm here:) I also did not like AVKON, but not because of its difficulty, but because the UI was really old, did not change too much since 2002 and while it is good for small screen keypad phones, definitely it needs fresh layout for touch devices...

    Another thing I believe Qt will enhance is a web browser based on WebKit, so it will have similar support for HTML5/CSS3 like Safari and Chrom...

    BR
    STEN



  • [quote author="stenlik" date="1291542946"]
    There are other points of view:

    1/ There was a community around Symbian Foundation, which will be lost
    2/ There was a huge number of good forum discussions, articles, etc. - all well structured
    3/ There was bug tracing, source code browsing, etc.
    4/ I do not remember any information when the SF was established that it is planned to be close at end of 2010, so what kind of signals it gives to people, like our customers, etc. - only the one, that there is some uncertainty...
    5/ Simply there was a single contact point towards OS, which was very good...[/quote]
    Yeah these are all valid points. And surprisingly, these are areas that Nokia has not planned to replicate.
    Community can move over here.
    But forum discussions/articles? You have to request on a DVD.
    Source code? Download it quick otherwise you'll need to request a DVD.
    Source code browsing? See above.

    I think there was a plan for it to close. But it seems they made no plans to move some of this critical information over to Nokia servers.

    As far as I understand (this stuff could change at any time), they plan to rewrite the core UI and all services and core apps in Qt. Web Browser, Ovi Maps, you name it.
    They will encourage Qt development and slowly kill off Avkon. Symbian C++ will still be available, but not recommended or used very much. This is probably a year away I figure.



  • Hi Tobias,

    [quote author="Tobias Hunger" date="1291541821"]Hi stenlik, welcome aboard!

    The code you give as an example is indeed most likely broken with regard to memory management. Most likely since somebody m* ight actually delete spinBox and slider manually at the right point.

    To detect memory leaks I usually run my application in valgrind on Linux (in the simulator). This works fine for me since I do not need to touch the native Symbian APIs.

    I have never been a huge fan for the memory leak reporting at the end of an application. It does little to help memory usage of the application. E.g. if I take 100k of memory every second the UI is up and clean that when I tear down the UI the end-of-application leak report will be fine, but I still have a huge resource problem. Real memory management tools (e.g. valgrind with massif) will help with this kind of issue.[/quote]

    Thanks for welcoming and nice answer - I agree with your point, but on the other way developers were forced to follow some minimal discipline and it helps in general - as the project is usually build and run after even small changes many times a day a lot of unseen leaks was catch + for unit tests __UHEAP_MARK like macros helps quite a lot.

    BR
    STeN



  • [quote author="stenlik" date="1291543167"]
    Another thing I believe Qt will enhance is a web browser based on WebKit, so it will have similar support for HTML5/CSS3 like Safari and Chrom...
    [/quote]

    There is several "QtWebKit browsers":http://developer.qt.nokia.com/wiki/ApplicationsUsingQtWebKit for Symbian actually.

    Check out: https://github.com/OrangeLabsUK/OrangeMobileBrowser
    Built by the telecom company, Orange, using Qt4.7 + QML + QtWebKit. It supports HTML5 among others. Currently has builds for Maemo. Symbian can compile but not official (yet!).



  • Hi,

    [quote author="xsacha" date="1291544797"]
    [quote author="stenlik" date="1291543167"]
    Another thing I believe Qt will enhance is a web browser based on WebKit, so it will have similar support for HTML5/CSS3 like Safari and Chrom...
    [/quote]

    There is several "QtWebKit browsers":http://developer.qt.nokia.com/wiki/ApplicationsUsingQtWebKit for Symbian actually.

    Check out: https://github.com/OrangeLabsUK/OrangeMobileBrowser
    Built by the telecom company, Orange, using Qt4.7 + QML + QtWebKit. It supports HTML5 among others. Currently has builds for Maemo. Symbian can compile but not official (yet!).[/quote]

    It looks interesting. I would like to try to use the QtWebKit for displaying the content created by web frameworks like Sencha Touch, jQTouch or jQuery Mobile, but I am not sure if it provides similar level of compatibility like Mobile Chrom or Safari, since those frameworks are usually optimized for them. I think in 4.7.x is the QtWebKit support much better then in 4.6.3 isn't it?? Unfortunately I am out of luck trying to use 4.7.1 with Symbian^3 for current time being.

    BR
    STeN



  • Yeah I've seen (other topic).
    Definitely, the QtWebKit improves dramatically with each revision. Unfortunately it's quite behind WebKit mainline (used in Chrome/Safari), but they are slowly catching up. This is why QtWebKit is separate install from Qt right now.

    This may interest you. It's Qt4.6.2 QtWebKit running on Symbian^3 with... Sencha Touch:
    http://www.youtube.com/watch?v=ERwS1sBRY-w

    Enjoy!

    Note the lagg will go away when it gets newer QtWebKit (300% performance improvement in QtWebKit 4.7), code matures and it starts to use graphics acceleration (all CPU now).



  • Hi,

    [quote author="xsacha" date="1291545643"]Yeah I've seen (other topic).
    Definitely, the QtWebKit improves dramatically with each revision. Unfortunately it's quite behind WebKit mainline (used in Chrome/Safari), but they are slowly catching up. This is why QtWebKit is separate install from Qt right now.

    This may interest you. It's Qt4.6.2 QtWebKit running on Symbian^3 with... Sencha Touch:
    http://www.youtube.com/watch?v=ERwS1sBRY-w

    Enjoy!

    Note the lagg will go away when it gets newer QtWebKit (300% performance improvement in QtWebKit 4.7), code matures and it starts to use graphics acceleration (all CPU now).[/quote]

    wow - that's good news it definitely looks promising!Thanks for the link.
    I have to try it asap -> hope I will be able finally to run 4.7.1 with S^3...

    BR
    STeN



  • That's by a group called 'ofi labs' that have a mind-dazzling amout of qtwebkit / browser stuff.
    Here's their git:
    http://gitorious.org/ofi-labs/x2
    They have some cool javascript game (runs in web browser) that detects accelerometer. '"MarbleBox":http://ariya.github.com/js/marblebox/' (also works in a laptop with accelerometer if you have one).

    And more in this wiki:
    http://developer.qt.nokia.com/wiki/Examples_from_Ofi_Labs

    The guy who made all that stuff is none other than "Engineering Director for Sencha":http://ariya.ofilabs.com/ ;)

    He also used to work for Trolltech (Qt) and Nokia. So I think Sencha support on Symbian/Qt is in safe hands.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.