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. How to minimize memory usage in runtime

How to minimize memory usage in runtime

Scheduled Pinned Locked Moved General and Desktop
17 Posts 6 Posters 16.9k Views
  • 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.
  • T Offline
    T Offline
    tobias.hunger
    wrote on last edited by
    #8

    Morris: How do you measure the memory usage? Tools like the task manager in windows are not up to the task. Better use tools like valgrind (Linux, I do not know of a good tool for windows).

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #9

      [quote author="Volker" date="1287937574"]There's hardly any solution to this problem, despite quitting and restarting the program.[/quote]

      So, in the end, will the app crash in such a scenario or ... ?

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #10

        bq.
        I do not know of a good tool for windows

        I've used Rational Purify on win32. But I continue to seek out and ask others for more tools on windows ... :(

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #11

          [quote author="chetankjain" date="1287937912"]So, in the end, will the app crash in such a scenario or ... ?[/quote]

          Not necessarily. In such a scenario the increase of memory cunsumption is usually very slow, as the memory manager still has plenty of unused memory on the heap that can be reallocated. For further details one should use tools like valgrind, as Tobias mentioned. There's always a possibility of real memory leaks - even in the Qt libs themselves ;-)

          If the memory consumption eventually stalls at a certain level, I'd leave it for that.

          BTW: The memory allocation on Windows is a bit weird, as each DLL has it's own memory management, AFAIK. That adds even more complexity to this topic.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Morris
            wrote on last edited by
            #12

            [quote author="Tobias Hunger" date="1287937783"]Morris: How do you measure the memory usage? Tools like the task manager in windows are not up to the task. Better use tools like valgrind (Linux, I do not know of a good tool for windows).[/quote]
            I'm using process explorer(the data it provides is pretty the same as windows 7 task manager's). It's better than the one in WinXp. Though it won't tell me how much RAM exactly does my app consume, but it provides a clue. And the users won't be satisfied if they read the high memory usage from the task manager.

            [quote author="chetankjain" date="1287937912"][quote author="Volker" date="1287937574"]There's hardly any solution to this problem, despite quitting and restarting the program.[/quote]

            So, in the end, will the app crash in such a scenario or ... ?[/quote]
            It's hard to make it crash this way, because you have so much memory. I'm not sure if is because heap fragmented. But at least I have check my code with Virtual Leak Detector, which tells me there's no leak(at least not in my code).

            [quote author="chetankjain" date="1287938069"]bq.
            I do not know of a good tool for windows

            I've used Rational Purify on win32. But I continue to seek out and ask others for more tools on windows ... :([/quote]
            I couldn't get Rational Purify to work. Is there any example?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mr_gui
              wrote on last edited by
              #13

              Same problem:

              a simple mainwindow with a pushbutton. When I run the "not-doing-anything program" for several minutes the private and shared physical memory of the programm rises some kb's. My OS is WinXP and I didn't get a Rational Purify license yet,so I use the "ProcessExplorer" of Microsoft Sysinternals instead. I don't know how reliable this tool is, but I encountered that at programm startup the private memory is at a certain level. When I minimize the programm, the private memory drops to very low, when I maximize it again the private memory rises but to only half the size as it was at program startup.
              Is this just the tool or what could it be?

              I have to build an application that runs several months without stopping so even slowly rising memory usage of the program could be fatal.

              Any suggestions?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #14

                mr_gui: Get yourself a good memory profiling tool.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mr_gui
                  wrote on last edited by
                  #15

                  hunger: thank you, have you any suggestions?

                  I tried VMMap now, better overview over program's memory.
                  Memory behaviour by minimizing and get back to old sizeof the program stays the same.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Morris
                    wrote on last edited by
                    #16

                    Thanks for the info, mr_gui~

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      blex
                      wrote on last edited by
                      #17

                      [quote author="mr_gui" date="1290688722"]I have to build an application that runs several months without stopping so even slowly rising memory usage of the program could be fatal.[/quote]

                      I have experience with qt3-based graphics applications that run more than 6 months on Windows XP. The memory usage is increased nearly 5 times from original (10 - 50M) but system reacts quickly.

                      If the application is running on Windows and uses custom dlls then look on utility rebase, it allows to specify the base address of the dll library. Specifying non-overlapping base address for all libraries significantly reduces physical memory usage. It is good optimization without code re-factoring :)

                      Also think about splitting the tray-indicator and main application in 2 independent processes, if it is possible. And start main process when it is requested from the tray icon.


                      Oleksiy Balabay

                      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