Application takes huge amount of ram
-
I made application with stacked widgets
The stacked widgets have 10 widgets inside
Some of the widgets have stacked widgets too.
There are 18 forms total. They are navigated with navigation bar.At the begining it takes more than 2GB of ram but the cpu and disk usage isn't that high.
It launches so slow too.

At first it says not responding. After almost 30 seconds the application opens and while using it , it takes more than 1GB of RAM
All of these data are taken from task manager
What can I do to solve this problem??
-
I made application with stacked widgets
The stacked widgets have 10 widgets inside
Some of the widgets have stacked widgets too.
There are 18 forms total. They are navigated with navigation bar.At the begining it takes more than 2GB of ram but the cpu and disk usage isn't that high.
It launches so slow too.

At first it says not responding. After almost 30 seconds the application opens and while using it , it takes more than 1GB of RAM
All of these data are taken from task manager
What can I do to solve this problem??
@Thank-You said in Application takes huge amount of ram:
What can I do to solve this problem??
Search for memory leaks in your app. On Linux you can use Valgrind for that.
Also you can disable parts of your app until it gets better, then you know where exactly to look. -
@Thank-You said in Application takes huge amount of ram:
What can I do to solve this problem??
Search for memory leaks in your app. On Linux you can use Valgrind for that.
Also you can disable parts of your app until it gets better, then you know where exactly to look.@jsulm
I am newbie at it 😂
Can you solve this
Stacked widgets with 10 forms like//in constructor { private: myFirstPage *fp = new myFirstPage(this); mySecondPage *sp = new mySecondPage(this); } //when some button is clicked void fClicked(){ myStackedWidget->setCurrentWidget(fp); } //again when another button is clicked void sClicked(){ myStackedWidget->setCurrentWidget(sp); }and so on
I haven't used delete at all
please share the technique to manage it -
@jsulm
I am newbie at it 😂
Can you solve this
Stacked widgets with 10 forms like//in constructor { private: myFirstPage *fp = new myFirstPage(this); mySecondPage *sp = new mySecondPage(this); } //when some button is clicked void fClicked(){ myStackedWidget->setCurrentWidget(fp); } //again when another button is clicked void sClicked(){ myStackedWidget->setCurrentWidget(sp); }and so on
I haven't used delete at all
please share the technique to manage it@Thank-You There is nothing to solve. You set parent, so fp and sp will be deleted as soon as the parent is deleted. And these widgets for sure do not consume 1GB of RAM! Since I don't know what your app is doing I can't say what the problem is. You have to provide more information. What is your app actually doing? Did you try to disable parts of it until it does not consume so much RAM?
-
@Thank-You There is nothing to solve. You set parent, so fp and sp will be deleted as soon as the parent is deleted. And these widgets for sure do not consume 1GB of RAM! Since I don't know what your app is doing I can't say what the problem is. You have to provide more information. What is your app actually doing? Did you try to disable parts of it until it does not consume so much RAM?
mainWin.h #ifndef MAINWIN_H #define MAINWIN_H #include <QMainWindow> #include<QProgressBar> #pragma once #include<database.h> #include<navigation.h> #include<QString> #include<QCloseEvent> #include<quitdialog.h> //for this only #include<dashboardform.h> #include<messagesform.h> #include<newshipmentform.h> #include<confirmationmodificationform.h> #include<accountform.h> #include<reportform.h> #include<morethingsform.h> #include<settingsform.h> #include<fullsettingsform.h> #include<currentlogin.h> QT_BEGIN_NAMESPACE namespace Ui { class mainwin; } QT_END_NAMESPACE class mainwin : public QMainWindow { Q_OBJECT public: mainwin(QWidget *parent = nullptr); ~mainwin(); void connections(); navigation *nav_bar; void closeEvent(QCloseEvent *event); database d; QString databaseName = d.getDatabaseName(); private slots: void logout_button_clicked_slot(); void new_shipment_button_clicked_slot(); void confirmation_button_clicked_slot(); void account_button_clicked_slot(); void more_button_clicked_slot(); void dashboard_button_clicked_slot(); void settings_button_clicked_slot(); void report_button_clicked_slot(); void advanced_button_clicked_slot(); void ham_burger_button_clicked_slot(); void messages_button_clicked_slot(); void quit_button_clicked_slot(); void on_menuDocumentation_triggered(); private: Ui::mainwin *ui; bool hamClicked; messagesForm *messages ; dashboardForm * dashboard ; newShipmentForm *newShipment; confirmationModificationForm * confirmationModification ; accountForm * account ; reportForm *report; moreThingsForm *moreThings; settingsForm * settings; fullSettingsForm *fullSettings; quitdialog closeApplication; bool closeApp; }; #endif // MAINWIN_Hthis is mainwin.cpp
#include "mainwin.h" #include "ui_mainwin.h" mainwin::mainwin(QWidget *parent) : QMainWindow(parent) , ui(new Ui::mainwin) { ui->setupUi(this); ui->mainApp->setCurrentIndex(0); connections(); hamClicked = true; ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); messages = ui->messages; dashboard = ui->dashboard; newShipment = ui->newShipment; confirmationModification = ui->confirmation; account = ui->account; report = ui->report; moreThings = ui->moreThings; settings = ui->settings; fullSettings = ui->fullSettings; } mainwin::~mainwin() { delete ui; } void mainwin::connections(){ nav_bar = ui->navigationBar; login *log = ui->loginPage; connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),nav_bar,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(logout_button_clicked_signal()),this,SLOT(logout_button_clicked_slot())); connect(nav_bar,SIGNAL(new_shipment_button_clicked_signal()),this,SLOT(new_shipment_button_clicked_slot())); connect(nav_bar,SIGNAL(confirmation_button_clicked_signal()),this,SLOT(confirmation_button_clicked_slot())); connect(nav_bar,SIGNAL(account_button_clicked_signal()),this,SLOT(account_button_clicked_slot())); connect(nav_bar,SIGNAL(more_button_clicked_signal()),this,SLOT(more_button_clicked_slot())); connect(nav_bar,SIGNAL(dashboard_button_clicked_signal()),this,SLOT(dashboard_button_clicked_slot())); connect(nav_bar,SIGNAL(settings_button_clicked_signal()),this,SLOT(settings_button_clicked_slot())); connect(nav_bar,SIGNAL(report_button_clicked_signal()),this,SLOT(report_button_clicked_slot())); connect(nav_bar,SIGNAL(advanced_button_clicked_signal()),this,SLOT(advanced_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->settings,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->messages,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(ham_burger_button_clicked_signal()),this,SLOT(ham_burger_button_clicked_slot())); connect(nav_bar,SIGNAL(messages_button_clicked_signal()),this,SLOT(messages_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->newShipment,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(&closeApplication,SIGNAL(quit_button_clicked_signal()),this,SLOT(quit_button_clicked_slot())); } void mainwin::logout_button_clicked_slot() { // it is default page ui->mainApp->setCurrentIndex(0); } void mainwin::new_shipment_button_clicked_slot() { ui->newShipment->clearValues(); ui->newShipment->mainFunction(); //ui->mainApp->setCurrentIndex(1); ui->mainApp->setCurrentWidget(newShipment); } void mainwin::confirmation_button_clicked_slot() { //ui->mainApp->setCurrentIndex(2); ui->mainApp->setCurrentWidget(confirmationModification); } void mainwin::account_button_clicked_slot() { ui->account->mainFunction(); // ui->mainApp->setCurrentIndex(3); ui->mainApp->setCurrentWidget(account); } void mainwin::more_button_clicked_slot() { // ui->mainApp->setCurrentIndex(4); ui->mainApp->setCurrentWidget(moreThings); } void mainwin::dashboard_button_clicked_slot() { ui->dashboard->mainFunction(); // ui->mainApp->setCurrentIndex(5); ui->mainApp->setCurrentWidget(dashboard); } void mainwin::settings_button_clicked_slot() { ui->dashboard->mainFunction(); // ui->mainApp->setCurrentIndex(6); ui->mainApp->setCurrentWidget(settings); } void mainwin::report_button_clicked_slot() { ui->report->mainFunction(); // ui->mainApp->setCurrentIndex(7); ui->mainApp->setCurrentWidget(report); } void mainwin::advanced_button_clicked_slot() { // ui->mainApp->setCurrentIndex(8); ui->mainApp->setCurrentWidget(fullSettings); } void mainwin::messages_button_clicked_slot() { // ui->mainApp->setCurrentIndex(9); ui->mainApp->setCurrentWidget(messages); } void mainwin::ham_burger_button_clicked_slot() { if(hamClicked){ ui->nav->setMaximumWidth(60); ui->nav->setMinimumWidth(60); hamClicked = false; }else{ ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); hamClicked = true; } } void mainwin::quit_button_clicked_slot() { closeApp = true; QCoreApplication::quit(); } void mainwin::closeEvent (QCloseEvent *event) { event->accept(); /*connect with logic*/ }These are main two files
All other are connected through this -
- You add these 10 widgets to the stacked widget one after another to see which one causes memory problem.
- if the memory usage goes up linearly, then checking one may be good enough. You use tools and ways to find that out.
-
If that is the case, simply select another version of Qt. I am not aware of Qt-5.12.8 has so many problems, especially in Qt5Core. Hard to imagine this.
If you have the same problem with another version of Qt(for example 5.15.2), it is likely your code(not Qt) has problem.
-
@Thank-You There is something fishy about either this tool (first time I see it) or your code. I write tools that use SQLite for everything, users leave those tools running for days sometimes and no extensive memory use have ever been detected. And we are talking about shitty windows budget office machines here.
I'd like to see the code before I'll decide that Qt libraries have issues with memory leaks on that scale.EDIT:
I started to google and found this post: https://www.francescmm.com/deleaker-review-on-gitqlient/
Author also found leaks in Qt libraries and states:This scared me a lot, because I wasn’t expecting to get so many leaks to start with. But I was wrong: when I took the snapshots, the objects are attached to the life of their parent widget. So, for now I don’t need to worry! -
@Thank-You There is something fishy about either this tool (first time I see it) or your code. I write tools that use SQLite for everything, users leave those tools running for days sometimes and no extensive memory use have ever been detected. And we are talking about shitty windows budget office machines here.
I'd like to see the code before I'll decide that Qt libraries have issues with memory leaks on that scale.EDIT:
I started to google and found this post: https://www.francescmm.com/deleaker-review-on-gitqlient/
Author also found leaks in Qt libraries and states:This scared me a lot, because I wasn’t expecting to get so many leaks to start with. But I was wrong: when I took the snapshots, the objects are attached to the life of their parent widget. So, for now I don’t need to worry!@artwaw I used Deleaker sir.
Followed official documentation to do my work but it just show this
On my application it says leaking in just 5 files and with very low allocation size whereas it shows huge allocation in QtLibraries
I have used SQLITE for fetching data in every page again it inserts data from all pages and keep tracks of every transaction.This is updated code that I use
I have promoted widgets in stacked widgetsJust updated version of upper codes
#ifndef MAINWIN_H #define MAINWIN_H #include <QMainWindow> #pragma once #include<database.h> #include<quitdialog.h> QT_BEGIN_NAMESPACE namespace Ui { class mainwin; } QT_END_NAMESPACE class mainwin : public QMainWindow { Q_OBJECT public: mainwin(QWidget *parent = nullptr); ~mainwin(); void connections(); void closeEvent(QCloseEvent *event); database d; QString databaseName = d.getDatabaseName(); private slots: void logout_button_clicked_slot(); void new_shipment_button_clicked_slot(); void confirmation_button_clicked_slot(); void account_button_clicked_slot(); void more_button_clicked_slot(); void dashboard_button_clicked_slot(); void settings_button_clicked_slot(); void report_button_clicked_slot(); void advanced_button_clicked_slot(); void ham_burger_button_clicked_slot(); void messages_button_clicked_slot(); void quit_button_clicked_slot(); void on_menuDocumentation_triggered(); private: Ui::mainwin *ui; bool hamClicked; bool closeApp; }; #endif // MAINWIN_HI remove all the pointers from here but there is no any gain in performance and is allocating same amount of memory
Below file is mainwin.cpp
#include "mainwin.h" #include "ui_mainwin.h" mainwin::mainwin(QWidget *parent) : QMainWindow(parent) , ui(new Ui::mainwin) { ui->setupUi(this); ui->mainApp->setCurrentIndex(0); connections(); hamClicked = true; ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); } mainwin::~mainwin() { delete ui; } void mainwin::connections(){ navigation *nav_bar = ui->navigationBar; login *log = ui->loginPage; connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),nav_bar,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(logout_button_clicked_signal()),this,SLOT(logout_button_clicked_slot())); connect(nav_bar,SIGNAL(new_shipment_button_clicked_signal()),this,SLOT(new_shipment_button_clicked_slot())); connect(nav_bar,SIGNAL(confirmation_button_clicked_signal()),this,SLOT(confirmation_button_clicked_slot())); connect(nav_bar,SIGNAL(account_button_clicked_signal()),this,SLOT(account_button_clicked_slot())); connect(nav_bar,SIGNAL(more_button_clicked_signal()),this,SLOT(more_button_clicked_slot())); connect(nav_bar,SIGNAL(dashboard_button_clicked_signal()),this,SLOT(dashboard_button_clicked_slot())); connect(nav_bar,SIGNAL(settings_button_clicked_signal()),this,SLOT(settings_button_clicked_slot())); connect(nav_bar,SIGNAL(report_button_clicked_signal()),this,SLOT(report_button_clicked_slot())); connect(nav_bar,SIGNAL(advanced_button_clicked_signal()),this,SLOT(advanced_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->settings,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->messages,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(ham_burger_button_clicked_signal()),this,SLOT(ham_burger_button_clicked_slot())); connect(nav_bar,SIGNAL(messages_button_clicked_signal()),this,SLOT(messages_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->newShipment,SLOT(login_button_clicked_slot(QString,QString,QString))); } void mainwin::logout_button_clicked_slot() { // it is default page ui->mainApp->setCurrentIndex(0); } void mainwin::new_shipment_button_clicked_slot() { ui->newShipment->clearValues(); ui->newShipment->mainFunction(); ui->mainApp->setCurrentWidget(ui->newShipment); } void mainwin::confirmation_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->confirmation); } void mainwin::account_button_clicked_slot() { ui->account->mainFunction(); ui->mainApp->setCurrentWidget(ui->account); } void mainwin::more_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->moreThings); } void mainwin::dashboard_button_clicked_slot() { ui->dashboard->mainFunction(); ui->mainApp->setCurrentWidget(ui->dashboard); } void mainwin::settings_button_clicked_slot() { ui->dashboard->mainFunction(); ui->mainApp->setCurrentWidget(ui->settings); } void mainwin::report_button_clicked_slot() { ui->report->mainFunction(); ui->mainApp->setCurrentWidget(ui->report); } void mainwin::advanced_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->fullSettings); } void mainwin::messages_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->messages); } void mainwin::ham_burger_button_clicked_slot() { if(hamClicked){ ui->nav->setMaximumWidth(60); ui->nav->setMinimumWidth(60); hamClicked = false; }else{ ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); hamClicked = true; } } void mainwin::quit_button_clicked_slot() { closeApp = true; QCoreApplication::quit(); } void mainwin::closeEvent (QCloseEvent *event) { quitdialog closeApplication; connect(&closeApplication,SIGNAL(quit_button_clicked_signal()),this,SLOT(quit_button_clicked_slot())); event->accept(); }In the main entrypoint of application I have just inserted css files using textstream from resources files
database.h contains all headers included
That's it
What may be the cause of it ?
EDIT:
In addition to it when I add dialog at the closeEvent then it reports
Insufficient Memory case 4 -
@artwaw I used Deleaker sir.
Followed official documentation to do my work but it just show this
On my application it says leaking in just 5 files and with very low allocation size whereas it shows huge allocation in QtLibraries
I have used SQLITE for fetching data in every page again it inserts data from all pages and keep tracks of every transaction.This is updated code that I use
I have promoted widgets in stacked widgetsJust updated version of upper codes
#ifndef MAINWIN_H #define MAINWIN_H #include <QMainWindow> #pragma once #include<database.h> #include<quitdialog.h> QT_BEGIN_NAMESPACE namespace Ui { class mainwin; } QT_END_NAMESPACE class mainwin : public QMainWindow { Q_OBJECT public: mainwin(QWidget *parent = nullptr); ~mainwin(); void connections(); void closeEvent(QCloseEvent *event); database d; QString databaseName = d.getDatabaseName(); private slots: void logout_button_clicked_slot(); void new_shipment_button_clicked_slot(); void confirmation_button_clicked_slot(); void account_button_clicked_slot(); void more_button_clicked_slot(); void dashboard_button_clicked_slot(); void settings_button_clicked_slot(); void report_button_clicked_slot(); void advanced_button_clicked_slot(); void ham_burger_button_clicked_slot(); void messages_button_clicked_slot(); void quit_button_clicked_slot(); void on_menuDocumentation_triggered(); private: Ui::mainwin *ui; bool hamClicked; bool closeApp; }; #endif // MAINWIN_HI remove all the pointers from here but there is no any gain in performance and is allocating same amount of memory
Below file is mainwin.cpp
#include "mainwin.h" #include "ui_mainwin.h" mainwin::mainwin(QWidget *parent) : QMainWindow(parent) , ui(new Ui::mainwin) { ui->setupUi(this); ui->mainApp->setCurrentIndex(0); connections(); hamClicked = true; ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); } mainwin::~mainwin() { delete ui; } void mainwin::connections(){ navigation *nav_bar = ui->navigationBar; login *log = ui->loginPage; connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),nav_bar,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(logout_button_clicked_signal()),this,SLOT(logout_button_clicked_slot())); connect(nav_bar,SIGNAL(new_shipment_button_clicked_signal()),this,SLOT(new_shipment_button_clicked_slot())); connect(nav_bar,SIGNAL(confirmation_button_clicked_signal()),this,SLOT(confirmation_button_clicked_slot())); connect(nav_bar,SIGNAL(account_button_clicked_signal()),this,SLOT(account_button_clicked_slot())); connect(nav_bar,SIGNAL(more_button_clicked_signal()),this,SLOT(more_button_clicked_slot())); connect(nav_bar,SIGNAL(dashboard_button_clicked_signal()),this,SLOT(dashboard_button_clicked_slot())); connect(nav_bar,SIGNAL(settings_button_clicked_signal()),this,SLOT(settings_button_clicked_slot())); connect(nav_bar,SIGNAL(report_button_clicked_signal()),this,SLOT(report_button_clicked_slot())); connect(nav_bar,SIGNAL(advanced_button_clicked_signal()),this,SLOT(advanced_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->settings,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->messages,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(ham_burger_button_clicked_signal()),this,SLOT(ham_burger_button_clicked_slot())); connect(nav_bar,SIGNAL(messages_button_clicked_signal()),this,SLOT(messages_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->newShipment,SLOT(login_button_clicked_slot(QString,QString,QString))); } void mainwin::logout_button_clicked_slot() { // it is default page ui->mainApp->setCurrentIndex(0); } void mainwin::new_shipment_button_clicked_slot() { ui->newShipment->clearValues(); ui->newShipment->mainFunction(); ui->mainApp->setCurrentWidget(ui->newShipment); } void mainwin::confirmation_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->confirmation); } void mainwin::account_button_clicked_slot() { ui->account->mainFunction(); ui->mainApp->setCurrentWidget(ui->account); } void mainwin::more_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->moreThings); } void mainwin::dashboard_button_clicked_slot() { ui->dashboard->mainFunction(); ui->mainApp->setCurrentWidget(ui->dashboard); } void mainwin::settings_button_clicked_slot() { ui->dashboard->mainFunction(); ui->mainApp->setCurrentWidget(ui->settings); } void mainwin::report_button_clicked_slot() { ui->report->mainFunction(); ui->mainApp->setCurrentWidget(ui->report); } void mainwin::advanced_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->fullSettings); } void mainwin::messages_button_clicked_slot() { ui->mainApp->setCurrentWidget(ui->messages); } void mainwin::ham_burger_button_clicked_slot() { if(hamClicked){ ui->nav->setMaximumWidth(60); ui->nav->setMinimumWidth(60); hamClicked = false; }else{ ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); hamClicked = true; } } void mainwin::quit_button_clicked_slot() { closeApp = true; QCoreApplication::quit(); } void mainwin::closeEvent (QCloseEvent *event) { quitdialog closeApplication; connect(&closeApplication,SIGNAL(quit_button_clicked_signal()),this,SLOT(quit_button_clicked_slot())); event->accept(); }In the main entrypoint of application I have just inserted css files using textstream from resources files
database.h contains all headers included
That's it
What may be the cause of it ?
EDIT:
In addition to it when I add dialog at the closeEvent then it reports
Insufficient Memory case 4 -
Unused stuff can get optimized out by the compiler hence no memory allocated.
Without any information about what the reports give you it's hard to answer.
Note that detectors might find false positives. For example Valgrind needs suppression files to remove some stuff that it detects as errors which are in fact not.
-
Unused stuff can get optimized out by the compiler hence no memory allocated.
Without any information about what the reports give you it's hard to answer.
Note that detectors might find false positives. For example Valgrind needs suppression files to remove some stuff that it detects as errors which are in fact not.
-
mainWin.h #ifndef MAINWIN_H #define MAINWIN_H #include <QMainWindow> #include<QProgressBar> #pragma once #include<database.h> #include<navigation.h> #include<QString> #include<QCloseEvent> #include<quitdialog.h> //for this only #include<dashboardform.h> #include<messagesform.h> #include<newshipmentform.h> #include<confirmationmodificationform.h> #include<accountform.h> #include<reportform.h> #include<morethingsform.h> #include<settingsform.h> #include<fullsettingsform.h> #include<currentlogin.h> QT_BEGIN_NAMESPACE namespace Ui { class mainwin; } QT_END_NAMESPACE class mainwin : public QMainWindow { Q_OBJECT public: mainwin(QWidget *parent = nullptr); ~mainwin(); void connections(); navigation *nav_bar; void closeEvent(QCloseEvent *event); database d; QString databaseName = d.getDatabaseName(); private slots: void logout_button_clicked_slot(); void new_shipment_button_clicked_slot(); void confirmation_button_clicked_slot(); void account_button_clicked_slot(); void more_button_clicked_slot(); void dashboard_button_clicked_slot(); void settings_button_clicked_slot(); void report_button_clicked_slot(); void advanced_button_clicked_slot(); void ham_burger_button_clicked_slot(); void messages_button_clicked_slot(); void quit_button_clicked_slot(); void on_menuDocumentation_triggered(); private: Ui::mainwin *ui; bool hamClicked; messagesForm *messages ; dashboardForm * dashboard ; newShipmentForm *newShipment; confirmationModificationForm * confirmationModification ; accountForm * account ; reportForm *report; moreThingsForm *moreThings; settingsForm * settings; fullSettingsForm *fullSettings; quitdialog closeApplication; bool closeApp; }; #endif // MAINWIN_Hthis is mainwin.cpp
#include "mainwin.h" #include "ui_mainwin.h" mainwin::mainwin(QWidget *parent) : QMainWindow(parent) , ui(new Ui::mainwin) { ui->setupUi(this); ui->mainApp->setCurrentIndex(0); connections(); hamClicked = true; ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); messages = ui->messages; dashboard = ui->dashboard; newShipment = ui->newShipment; confirmationModification = ui->confirmation; account = ui->account; report = ui->report; moreThings = ui->moreThings; settings = ui->settings; fullSettings = ui->fullSettings; } mainwin::~mainwin() { delete ui; } void mainwin::connections(){ nav_bar = ui->navigationBar; login *log = ui->loginPage; connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),nav_bar,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(logout_button_clicked_signal()),this,SLOT(logout_button_clicked_slot())); connect(nav_bar,SIGNAL(new_shipment_button_clicked_signal()),this,SLOT(new_shipment_button_clicked_slot())); connect(nav_bar,SIGNAL(confirmation_button_clicked_signal()),this,SLOT(confirmation_button_clicked_slot())); connect(nav_bar,SIGNAL(account_button_clicked_signal()),this,SLOT(account_button_clicked_slot())); connect(nav_bar,SIGNAL(more_button_clicked_signal()),this,SLOT(more_button_clicked_slot())); connect(nav_bar,SIGNAL(dashboard_button_clicked_signal()),this,SLOT(dashboard_button_clicked_slot())); connect(nav_bar,SIGNAL(settings_button_clicked_signal()),this,SLOT(settings_button_clicked_slot())); connect(nav_bar,SIGNAL(report_button_clicked_signal()),this,SLOT(report_button_clicked_slot())); connect(nav_bar,SIGNAL(advanced_button_clicked_signal()),this,SLOT(advanced_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->settings,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->messages,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(nav_bar,SIGNAL(ham_burger_button_clicked_signal()),this,SLOT(ham_burger_button_clicked_slot())); connect(nav_bar,SIGNAL(messages_button_clicked_signal()),this,SLOT(messages_button_clicked_slot())); connect(log,SIGNAL(login_button_clicked_signal(QString , QString, QString)),ui->newShipment,SLOT(login_button_clicked_slot(QString,QString,QString))); connect(&closeApplication,SIGNAL(quit_button_clicked_signal()),this,SLOT(quit_button_clicked_slot())); } void mainwin::logout_button_clicked_slot() { // it is default page ui->mainApp->setCurrentIndex(0); } void mainwin::new_shipment_button_clicked_slot() { ui->newShipment->clearValues(); ui->newShipment->mainFunction(); //ui->mainApp->setCurrentIndex(1); ui->mainApp->setCurrentWidget(newShipment); } void mainwin::confirmation_button_clicked_slot() { //ui->mainApp->setCurrentIndex(2); ui->mainApp->setCurrentWidget(confirmationModification); } void mainwin::account_button_clicked_slot() { ui->account->mainFunction(); // ui->mainApp->setCurrentIndex(3); ui->mainApp->setCurrentWidget(account); } void mainwin::more_button_clicked_slot() { // ui->mainApp->setCurrentIndex(4); ui->mainApp->setCurrentWidget(moreThings); } void mainwin::dashboard_button_clicked_slot() { ui->dashboard->mainFunction(); // ui->mainApp->setCurrentIndex(5); ui->mainApp->setCurrentWidget(dashboard); } void mainwin::settings_button_clicked_slot() { ui->dashboard->mainFunction(); // ui->mainApp->setCurrentIndex(6); ui->mainApp->setCurrentWidget(settings); } void mainwin::report_button_clicked_slot() { ui->report->mainFunction(); // ui->mainApp->setCurrentIndex(7); ui->mainApp->setCurrentWidget(report); } void mainwin::advanced_button_clicked_slot() { // ui->mainApp->setCurrentIndex(8); ui->mainApp->setCurrentWidget(fullSettings); } void mainwin::messages_button_clicked_slot() { // ui->mainApp->setCurrentIndex(9); ui->mainApp->setCurrentWidget(messages); } void mainwin::ham_burger_button_clicked_slot() { if(hamClicked){ ui->nav->setMaximumWidth(60); ui->nav->setMinimumWidth(60); hamClicked = false; }else{ ui->nav->setMinimumWidth(200); ui->nav->setMaximumWidth(200); hamClicked = true; } } void mainwin::quit_button_clicked_slot() { closeApp = true; QCoreApplication::quit(); } void mainwin::closeEvent (QCloseEvent *event) { event->accept(); /*connect with logic*/ }These are main two files
All other are connected through thisProfile your application to see what eats memory.
@Thank-You said in Application takes huge amount of ram:
database d;
That thing here we know nothing about so it might be as well it that is leaking memory depending on how you use it and what it does.
-
Profile your application to see what eats memory.
@Thank-You said in Application takes huge amount of ram:
database d;
That thing here we know nothing about so it might be as well it that is leaking memory depending on how you use it and what it does.
#ifndef DATABASE_H #define DATABASE_H #pragma once #include<QString> #include<QFile> #include<QMessageBox> #include<QDebug> #include<ctime> #include<QTextStream> #include<errorsexpress.h> #include<QSql> #include<QtSql/QSql> #include<QtSql/QSqlDatabase> #include<QtSql/QSqlQuery> #include<QtSql/QSqlDriver> #include<QtSql/QSqlQuery> #include<QtSql/QSqlQueryModel> #include<QSqlError> class database { public: database(); QString readTextFile(QString path); QString getDatabaseName(); QString getUsername(); QString getId(); QString getPost(); void saveRequest(QString user_id ,QString special_value, QString operation,QString page); ErrorsExpress ERRORS; }; #endif // DATABASE_Hdatabase.cpp implements just these functions straight forward. Contains all headers that are needed in every other files
It is included in every files.
Please say something on these
But if I leave the application for about 5 minutes ,
it just takes 120 - 160mb or less than that of ram .
What may be the reason -
Since you have a database, what are you loading from it ?
-
How many transaction are we looking at ?
How are you storing them ? -
@SGaist
FIXED BUT
I have 9 tables with max 28 columns and min of 8 columns.
On every database query I am using saving type of query(like on every transaction)
Sir problem is solved now. I uninstalled and installed the Qt(same offline installer). It is using just 200-300mb ram on average and it's not that problem. I don't know the reason but problem is fixed. The problem is fixed but do you have any idea , why this happened?
