Qt Application Slowing Down
-
Hi
Do you use any images in your app ? load them etc ?
Not icons but huge images or similar ?
To use 4GB you have to have something a bit heavy as
clicking back and forth to leak that much using only widgets seems
to would take a long time.
You have to look over all places again and try to guess where it is not assigned a parent
and/or not flagged for delete on close.@mrjj yess am using 12kb size image
-
Hi
ok that's not so much.
look for new in loop and such places.How fast does it take to get "slow" ?
-
Hi
ok that's not so much.
look for new in loop and such places.How fast does it take to get "slow" ?
@mrjj within 5 min it starts getting slow
once i got to main window application works normal speed for another 5 min
and again if i back and forth the some other dialog it become slower -
@mrjj within 5 min it starts getting slow
once i got to main window application works normal speed for another 5 min
and again if i back and forth the some other dialog it become slower@swansorter
Ok. That's pretty fast.
Does seems related to navigating the app.
I would set breakpoints in all dialogs destructors to make sure they are deleted.
and generally, look over the code verify that you free stuff. -
Hi,
From the look of the code you posted, you are re-creating at least your main window each time you call your settings dialog. If you do that with all your dialogs and maybe other widgets, it's not really surprising that the memory gets eaten up.
You should take a look at the more complex Qt example on how to handle a QMainWindow with one or more dialogs.
Still based on your code and ve fact that you are using images, how are you handling them ?
-
Hi,
From the look of the code you posted, you are re-creating at least your main window each time you call your settings dialog. If you do that with all your dialogs and maybe other widgets, it's not really surprising that the memory gets eaten up.
You should take a look at the more complex Qt example on how to handle a QMainWindow with one or more dialogs.
Still based on your code and ve fact that you are using images, how are you handling them ?
@SGaist i searched but found nothing ...
please share the link of any Qt example program -
@swansorter said in Qt Application Slowing Down:
please share the link of any Qt example program
-
@swansorter said in Qt Application Slowing Down:
please share the link of any Qt example program
@Christian-Ehrlicher i need example like QMainWindow with two or more dialogs.
-
Having two dialogs or one doesn't change things much.
What do you search exactly with an example with two dialogs ?
-
Having two dialogs or one doesn't change things much.
What do you search exactly with an example with two dialogs ?
@SGaist yea...qt dialog with more than two dialog
-
@SGaist yea...qt dialog with more than two dialog
@swansorter If you can create one dialog you can create 2 or 3 or 4 or ...
So, what exactly is the problem? -
@swansorter If you can create one dialog you can create 2 or 3 or 4 or ...
So, what exactly is the problem?@jsulm 1. we have different screens like home screen ,setting screen ,main sort screen , resort1 ,resort2 and resort 3 screens
2.On "home screen" we have setting button.
3.we move to the "setting screen" with code like the following:-settingDialog *sd=new settingDialog(this); sd->setModal(true); close(); //closes the home window sd->setAttribute( Qt::WA_DeleteOnClose); sd->exec();//shows the setting screen
4.On "Setting screen" we have main sort screen Button ,resort1 ,2 ,3 screen buttons to move respective screens.
5.we move to the "main sort screen" with code like the following:-
mainSortDialog *ms=new mainSortDialog();
ms->setModal(true);
ms->setAttribute ( Qt::WA_DeleteOnClose, true );
this->close();//closes the setting screen
ms->exec();//shows the main sort window6.on "main sort screen" we have Back button to go back to "setting screen".
-
we move to the "main sort screen" with code like the following:-
sd=new settingDialog();
sd->setAttribute ( Qt::WA_DeleteOnClose, true );
sd->setModal(true);
this->close();//closes the main sort screen
sd->exec();//shows the setting screen
8.if i do the step 5 and 7 continuously the application gets slower .
-
-
@jsulm 1. we have different screens like home screen ,setting screen ,main sort screen , resort1 ,resort2 and resort 3 screens
2.On "home screen" we have setting button.
3.we move to the "setting screen" with code like the following:-settingDialog *sd=new settingDialog(this); sd->setModal(true); close(); //closes the home window sd->setAttribute( Qt::WA_DeleteOnClose); sd->exec();//shows the setting screen
4.On "Setting screen" we have main sort screen Button ,resort1 ,2 ,3 screen buttons to move respective screens.
5.we move to the "main sort screen" with code like the following:-
mainSortDialog *ms=new mainSortDialog();
ms->setModal(true);
ms->setAttribute ( Qt::WA_DeleteOnClose, true );
this->close();//closes the setting screen
ms->exec();//shows the main sort window6.on "main sort screen" we have Back button to go back to "setting screen".
-
we move to the "main sort screen" with code like the following:-
sd=new settingDialog();
sd->setAttribute ( Qt::WA_DeleteOnClose, true );
sd->setModal(true);
this->close();//closes the main sort screen
sd->exec();//shows the setting screen
8.if i do the step 5 and 7 continuously the application gets slower .
@swansorter said in Qt Application Slowing Down:
if i do the step 5 and 7 continuously the application gets slower
Then you have to investigate.
Did you check CPU usage of your app?
Did you check RAM usage of your app? -
-
Hi
Also did you CHECK that your dialogs are in fact - deleted?
By breakpoints in their destructors.
WA_DeleteOnClose should take care of that but its good to check. -
Hi
Also did you CHECK that your dialogs are in fact - deleted?
By breakpoints in their destructors.
WA_DeleteOnClose should take care of that but its good to check.@mrjj yea checked.....execution of destructors are happening only when i moved to main window
-
@mrjj yea checked.....execution of destructors are happening only when i moved to main window
Well is that the issue then?
If you dont move to mainwin, they are not freed,
so if u never do that then it grows.
or ? -
Well is that the issue then?
If you dont move to mainwin, they are not freed,
so if u never do that then it grows.
or ?@mrjj yes that is the issu..
how to free the object when the perticular screen "dialog" close? -
@mrjj yes that is the issu..
how to free the object when the perticular screen "dialog" close?@swansorter
well first of all you can clean up the places where newing is not needed.
All places where you use exec() for dialogs could just bevoid class::insomefunc() { mainSortDialog ms; this->close();//closes the setting screen ms->exec(); }
and it would be cleaned up as soon as dialog is closed.
So unless you are not using exec() there should be no reason to new it.
and hence that could auto clean lots for you. -
@swansorter
well first of all you can clean up the places where newing is not needed.
All places where you use exec() for dialogs could just bevoid class::insomefunc() { mainSortDialog ms; this->close();//closes the setting screen ms->exec(); }
and it would be cleaned up as soon as dialog is closed.
So unless you are not using exec() there should be no reason to new it.
and hence that could auto clean lots for you.@mrjj i tried this one ... working for me
thank you -
@mrjj i tried this one ... working for me
thank you@swansorter
Good. hopefully it can also cure the leaking.