When I write a Picasa application using Webkit + HTML + Javascript, the memory cost is always increasing!



  • I write a hybrid app to get the Picasa pictures using QT Webkit and HTML+Javascript. In my application, there are 2 html pages, one is Featured photos(I name it as A) to get pictures from Picasa, the other one(I name it as B) is a normal html page with no function. And I met a problem about the memory cost:

    1. When I launch the app, A is showing, the memory size is 40M;
    2. When I click an html tag to jump to B, the memory size is 38M;
    3. When back to A from B, the memory size is 42M;
    4. When back to B from A, the memory size is 40M;
    5. When back to A from B, the memory size is 44M;

    It means when the A is showing, the memory size is added 2M. It seems like a memory leak of webkit?
    I searched a lot but has no solution. Please help!
    Appreciate!!



  • Added:
    My QT SDK version is 4.7.4, Webkit version is 2.1



  • I think this is related to JavaScript. See these links for more information about the issue.

    "link1":http://old.nabble.com/Leak-reports-during-shutdown-td25668090.html
    "link2":https://bugreports.qt-project.org/browse/QTBUG-6426



  • So, is it still a bug? It means we can not develop hybird applications using QT Webview + HTML + Javascript?!



  • These bug reports are form 2009 and 2010. It would be surprising if they where still there. Are we even using the same Javascript interpreter still? :-)

    Of course to debug memory leaks, it is possible to run the application in Valgrind and see what happens. My initial response to @qdhuxp was that I assume the observed behavior is due to caching of HTML and Javascript code objects.



  • @miroslav I know the bug reports are quite old, but since the answer to these reports always was that the memory leaks are related to javascripts garbage collection behaviour, I assumed that this behaviour was not considered to be a bug and is most likely still present in the current Webkit version.



  • As far as I understand your page A (or some native stuff that gets executed when page A is shown) claims memory which is not freed when you exit page A (i.e. navigation to page B).

    Because it's a hybrid application your memory leaks can occure

    • in the web part, i.e. in your HTML pages and your JavaScript
    • in the native part.

    Try to get rid of the native part and load your html pages in a standalone browser, like chrome, firefox, safari etc. if you see the problems there too, then it's a leak in the JavaScript part. Of course I do not know if you can get rid of your native part and display the pages alone...? If you see it leaking it can be either an JS engine problem or (and unfortunately that's the common case) it's a problem in your JavaScript coding, because you have cross references or whatsoever.

    Of course it can be also a memory heap problem in your native part. Take a look if you allocate memory with new or new[] if you show page A and be sure that you did not forget the delete or delete[] if you navigate back from your page. What about your QObject instance with which you have to populate your page A by calling @addToJavaScriptWindowObject("YOUR_BRIDGE_NAME", qObjectInstance)@

    For sure this is always done as soon as you show page A.


Log in to reply
 

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