Results 1 to 5 of 5

Thread: memory increase when use PageStack

  1. #1
    Join Date
    Jun 2011
    Posts
    35
    Thanks
    16
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Default memory increase when use PageStack

    when i use PageStack between pages then memory increase. From Main.qml, i call page MainPage.qml . after that i call page PageDetail.qml . Memory increase but i go back page MainPage.qml then memory does not decrease

    this is my code

    main.qml

    Qt Code:
    1. import com.nokia.symbian 1.0
    2.  
    3. Window {
    4. id: window
    5.  
    6. StatusBar {
    7. id: statusBar
    8. anchors.top: window.top
    9. }
    10.  
    11. PageStack {
    12. id: pageStack
    13. anchors { left: parent.left; right: parent.right; top: statusBar.bottom; bottom: toolBar.top }
    14. }
    15.  
    16. ToolBar {
    17. id: toolBar
    18. anchors.bottom: window.bottom
    19. tools: ToolBarLayout {
    20. id: toolBarLayout
    21. ToolButton {
    22. flat: true
    23. iconSource: "toolbar-back"
    24. onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
    25. }
    26. }
    27. }
    28.  
    29. Component.onCompleted: {
    30. pageStack.push(Qt.resolvedUrl("MainPage.qml"))
    31.  
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    MainPage.qml

    Qt Code:
    1. import QtQuick 1.0
    2. import com.nokia.symbian 1.0
    3.  
    4. Page {
    5. id: mainPage
    6. Text {
    7. id: text1
    8. anchors.centerIn: parent
    9. text: qsTr("Hello world!")
    10. color: platformStyle.colorNormalLight
    11. font.pixelSize: 20
    12. }
    13.  
    14. Button{
    15. width: 150
    16. text :"page 2"
    17. anchors.horizontalCenter: parent.horizontalCenter
    18. anchors.top: text1.bottom
    19. anchors.topMargin: 10
    20. onClicked: {
    21.  
    22. pageStack.push(Qt.resolvedUrl("PageDetail.qml"))
    23. }
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    PageDetail.qml

    i
    Qt Code:
    1. mport QtQuick 1.0
    2. import com.nokia.symbian 1.0
    3.  
    4. Page {
    5. Button {
    6. id: button1
    7. x: 142
    8. y: 437
    9. text: "Tro ve"
    10. onClicked: pageStack.pop()
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    how to decrease memory when go back page ManiPage.qml ?
    thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: memory increase when use PageStack

    It's not a memory leak, it's quite normal since going back to the original page doesn't cause the previous one to be destroyed, you can still access its components.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    jindoniit (27th September 2011)

  4. #3
    Join Date
    Jun 2011
    Posts
    35
    Thanks
    16
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Default Re: memory increase when use PageStack

    so , how to way to destroy PageDetail.qml when go back page MainPage.qml?

    my project has many page .and when i move between pages then memory increase. it can lead to out of memory

  5. #4
    Join Date
    Oct 2011
    Posts
    1
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: memory increase when use PageStack

    You have many ways to delete pages, for example with PageStack.clear() but you go to delete all your pages, including the current one.

    For example i use that to clean the memory:

    Qt Code:
    1. pageStack.clear()
    2. pageStack.push( Qt.resolvedUrl("SecondPage.qml"))
    To copy to clipboard, switch view to plain text mode 

    Or you can replace the current page, with
    Qt Code:
    1. pageStack.replace()
    To copy to clipboard, switch view to plain text mode 
    but you dont go to have the back function.

    Hope that helps

  6. #5
    Join Date
    Jun 2011
    Posts
    35
    Thanks
    16
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Default Re: memory increase when use PageStack

    I tried to follow way of you. and as you said :it delete all my pages . so what do you have way to reduce memory when use pagestack.pop() ?

Similar Threads

  1. how to increase the transparency of Qpainter?
    By athulms in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2011, 06:16
  2. How to increase available RAM for Qt Creator?
    By fezvez in forum Qt Tools
    Replies: 4
    Last Post: 19th April 2011, 21:37
  3. Increase QPainter performance
    By travelan in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2009, 11:52
  4. Replies: 8
    Last Post: 1st June 2009, 19:59
  5. Increase the height of titlebar, ...
    By vql in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2008, 11:28

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.