How to minimize memory usage in runtime
-
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 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 ... ?
-
bq.
I do not know of a good tool for windowsI've used Rational Purify on win32. But I continue to seek out and ask others for more tools on windows ... :(
-
[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.
-
[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 windowsI'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? -
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?
-
mr_gui: Get yourself a good memory profiling tool.
-
[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.