Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Minimizing window to tray will not lower the memory used!
Forum Updated to NodeBB v4.3 + New Features

Minimizing window to tray will not lower the memory used!

Scheduled Pinned Locked Moved General and Desktop
9 Posts 6 Posters 2.7k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    12.2 Mb when window is not minimized

    !http://i.imgur.com/l0f6S.png(1)!

    12.1 Mb when window is hidden and minimized to tray

    !http://i.imgur.com/DCx6t.png(2)!

    5.9 Mb when program started from an argument that doesn't show the GUI

    !http://i.imgur.com/orwV1.png(3)!

    So how can we achive 5.9 when the user minimizes the window to tray?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You would have to delete all the GUI objects. Normally they remain untouched - only the visibility changes.

      (Z(:^

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        u mean
        delete ui->addbutton;
        and so on at all the 100 widgets that we have in the mainwindow?

        I just need to add here that all the widgets that are on the mainwindow are in a stackedwidget... but deleting it, will "The program has unexpectedly finished."...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlekseyOk
          wrote on last edited by
          #4

          If you'll make

          @delete ui->button;@

          than after restoring of window you should make something like this

          @ui->button = new QPushButton;@

          or do not call delete <bla-bla-bla>;

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            As Aleksey noted.

            Personally, I would not bother. It would take you a lot of time to make it all work flawlessly, while most users can afford that 5MB of RAM for your app...

            (Z(:^

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on last edited by
              #6

              ... and even if you do the operating system (or the system library) most probably will not bother reclaiming that small amount of memory, which nullifies the effect completely.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Leon
                wrote on last edited by
                #7

                Well u know wallch takes 12 mb when u haven't loaded anything.. if i add some items to the listwidget i have in the mainwindow, the memory raises to 31 mb..

                !http://i.imgur.com/Iol52.jpg(1)!

                that means it's not a 5 mb difference its a 25 mb difference..

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DerManu
                  wrote on last edited by
                  #8

                  You still can't force the OS to reclaim that memory, or even make Qt give it back. For example, the memory of Qt containers isn't returned to the OS but kept for subsequent (re-)allocations. STL containers behave the same, it's a (reasonable) design choice, and there's nothing you can do about it.

                  You're worrying about 0.4% of most users' ram. While I generally encourage responsible handling of your users' resources, I'm sure there are more important things to work on in your application than this.

                  Still, let me discuss my proposal:
                  Don't go the way to delete your UI elements, it won't work. By this you will introduce masses of bugs and instability. Apart from the already mentioned problem of non-effective memory deallocation.
                  Rather split your application in two: One low-resource daemon, and one GUI application. The daemon is a background process which handles the background changing. If the user wants to configure something, he starts the GUI which communicates with the daemon. If he's done, he closes the configuration program, which then really frees all that GUI-Memory. This is the only sensible approach I see for such an application.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Asperamanca
                    wrote on last edited by
                    #9

                    Well, not quite true about the containers. QVector has a squeeze() method to free up unused memory.

                    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