PDA

View Full Version : Memory management problem



zloigall
23rd July 2012, 23:08
Hello.

Tried to create(with new) a lot of QSubWindows with some elements and then close and destroy subwindow and its elements( with delete). After this checked memory usage and its still connected to my programm. Checked with valgrind and its seems to be alright but memory usage only increasing with time.I understand this is normal for Qt to not give it back to system. But i would prefer to give it back, or at least avoid this kind of behaviour.Google says its can be avoided if i would go to main event loop periodicaly. But how can it be done?

Thanks beforehand))

amleto
24th July 2012, 12:43
just because the o/s says there is X mb/kb allocated to an app, it does not mean that the app is using it all.

Santosh Reddy
24th July 2012, 14:41
If you sure that memory management within your application ok (with proper parent hierarchy, and new(s) and delete(s) and valgrind report), then stop worrying about how much memory that system is reporting, it may look like increasing but run it over a considerable time (this depends on your application dynamic object's life cycles)

Just a trick to try, minimize the Qt application window, and see the memory usage!

zloigall
25th July 2012, 12:06
Thanks)))I know,you can forget about memory if yours app gets about 20-100 mb. But what if its gets 500 mb when you have 1gb or 512 mb of ram?I tested it with a few examples of the same programm running at the same time. When memory was almost gone,some of alloced to app memory was returned to another process.But everything was working slowly.Thats why i need to control how much memory its geting from system.

wysota
25th July 2012, 16:16
Thanks)))I know,you can forget about memory if yours app gets about 20-100 mb. But what if its gets 500 mb when you have 1gb or 512 mb of ram?
The system will reclaim memory if it is needed for something else. "Free" memory is wasted memory.


But everything was working slowly.Thats why i need to control how much memory its geting from system.
You do that by configuring the system properly.