memory usage with QT Widgets
-
wrote on 1 Nov 2022, 09:31 last edited by
My app has many forms that Inherits from QWidget.
I create them and set visibility at false to show only one at a time.
The memory usage is 1200MB.
Is this normal with Qt widgets?
Can I reduce memory usage ?Thanks
-
My app has many forms that Inherits from QWidget.
I create them and set visibility at false to show only one at a time.
The memory usage is 1200MB.
Is this normal with Qt widgets?
Can I reduce memory usage ?Thanks
-
wrote on 1 Nov 2022, 11:04 last edited by
@JonB hello Jon!
I have 100 rows like this:
pcontainer_panel_map_stc = new container_panel_map_stc();
pcontainer_panel_map_stc ->hide();with different containers, each one inherits from widget and have enbedded widgest.....
I understand all the allocated memory with so many forms instanciated at start up, but i was wondering if i can do something to reduce memory usage.
If i do the "new" only to the current visible form, the user will see a delay in the form showing, and i don't want this.
Do you have some idea?
thanks ! -
@JonB hello Jon!
I have 100 rows like this:
pcontainer_panel_map_stc = new container_panel_map_stc();
pcontainer_panel_map_stc ->hide();with different containers, each one inherits from widget and have enbedded widgest.....
I understand all the allocated memory with so many forms instanciated at start up, but i was wondering if i can do something to reduce memory usage.
If i do the "new" only to the current visible form, the user will see a delay in the form showing, and i don't want this.
Do you have some idea?
thanks !wrote on 1 Nov 2022, 11:16 last edited by@pedrito
Impossible to say how much memory needed, since you tell me you have 100 rows with "enbedded widgest" but give absolutely no indication how many widgets per row, so no one can say. I am still surprised it occupies 1.2GB, I guess you have tens of hundreds of thousands of widgets...? Seems excessive....but i was wondering if i can do something to reduce memory usage.
If i do the "new" only to the current visible form, the user will see a delay in the form showing, and i don't want this.
So you would like to reduce the memory usage, but wish to create all the widgets and are not prepared to create/destroy them on demand. You want to have your cake and eat it. You would like to create the hundreds of thousands of widgets on start up but magically have them not take up memory, right? I would try prayer....
- Create/destroy the widgets on demand to reduce memory.
- Reduce the total number from the hundreds of thousands you appear to have.
- Re-use some widgets/containers instead of creating separate ones.
- Pray for a miracle whereby you allocate all the memory in advance for the widgets yet this miraculously does not use the memory....
-
@pedrito
Impossible to say how much memory needed, since you tell me you have 100 rows with "enbedded widgest" but give absolutely no indication how many widgets per row, so no one can say. I am still surprised it occupies 1.2GB, I guess you have tens of hundreds of thousands of widgets...? Seems excessive....but i was wondering if i can do something to reduce memory usage.
If i do the "new" only to the current visible form, the user will see a delay in the form showing, and i don't want this.
So you would like to reduce the memory usage, but wish to create all the widgets and are not prepared to create/destroy them on demand. You want to have your cake and eat it. You would like to create the hundreds of thousands of widgets on start up but magically have them not take up memory, right? I would try prayer....
- Create/destroy the widgets on demand to reduce memory.
- Reduce the total number from the hundreds of thousands you appear to have.
- Re-use some widgets/containers instead of creating separate ones.
- Pray for a miracle whereby you allocate all the memory in advance for the widgets yet this miraculously does not use the memory....
wrote on 1 Nov 2022, 11:20 last edited byok. you are right Jon. Really thank you for the explanation!
-
wrote on 2 Nov 2022, 09:46 last edited by
I expect that not all 100 rows are visible at the same time. You should try to only have the widgets allocated/created that are also visible. When you scroll you have to switch out rows to display. Usually, this is also a really bad user experience as it takes to long to open. You app will freeze for seconds and only when all widgets are created will it be responsive to the user again. This is really frustrating for the user. Most users will assume your software is not doing anything anymore and will try to close it and reopen.
1/6