Solved Application crashes when loading database on weak notebook
-
Hi!
In my application, I load a SQLite database (not very big, not very small) with QSQLite// open Database QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); QString fileName = QFileDialog::getOpenFileName(this, "select project database", QDir::currentPath() + "/custom content/saves"); if(!fileName.endsWith(".db")){ ui->statusBar->showMessage("not a valid .db file"); return; } db.setDatabaseName(fileName); if(!db.open()){ ui->statusBar->showMessage("wasn't able to open the database"); } QSqlQuery query; // doing things with the database
I develop the program on my desk, I don't get any problem in Qt Creator and the exported version on my desk. But running the exported version on my (relatively weak) notebook causes often (90%) a crash when trying to load the database.
What did I do wrong? Shouldnt the program just load longer on the notebook, but never crash if it doesn't on my desk?
Thanks for answers -
@Niagarer
hard to say without knowing details.
It might be that the application runs out of memory on your notebook? If it can't allocate needed memory the application has to crash.How much RAM does the notebook have? Note that every other program running (including the OS) consumes RAM.
Whats the memory consumption on the machine? -
@raven-worx
Thanks for the fast reply. I don't think, the memory is the problem, I just tried with 1.1 GB of free RAM (of 4 GB total), same result, a significant growth of memory usage when I imported the database was not recognizable (task manager, Windows 10). -
@Niagarer
then its hard to say.
You wil have the highest chances when debugging directly on the machine. -
Hi,
What size is the database ?
Are you working in 32 or 64bit ? -
@SGaist
64bit and the size is 44 KB -
Are you sure all your dependencies are satisfied?
Are you sure it crashes during the loading of the database and not somewhere else?
-
@Niagarer Looks like an excellent case for logging.
Add debug outputs on several places and see what the last output before the crash is.
That will also help you to debug your app when it is used far away.
http://blog.qt.io/blog/2014/03/11/qt-weekly-1-categorized-logging/
-
@MrShawn said in Application crashes when loading database on weak notebook:
Are you sure all your dependencies are satisfied?
well on the desk it works, so I think so
Are you sure it crashes during the loading of the database and not somewhere else?
I can't guaratee, that it's the query or something in direct connection. All other stuff I do there should be legitim, but I can't guarantee (but, yes it's hard to say, because 90% of the time, I don't get any problems on my machine and the other 10% don't come from something specific, I can do the same thing multiple times, sometimes it crashes, normally it doesn't)
@aha_1980 thanks for the tip, I will take a closer look on that
-
Do you have other application that crashes randomly like that on your notebook ?
Are you running anything else in parallel ?
What are the specs of your notebook ? -
@SGaist said in Application crashes when loading database on weak notebook:
Do you have other application that crashes randomly like that on your notebook ?
nope
Are you running anything else in parallel ?
nope
What are the specs of your notebook ?
- Intel processor
- 2.4 GHz
- 2 cores
- 4 GB DDR3 RAM
- 2x64 GB SSD
- Graphics Processor: Intel HD Graphics 500
- Windows 10
-
Model of Intel processor ?
-
sorry,
- Intel Celeron N3350 - 2 MB, Dual Core
-
I just discovered, that somtimes the application even crashes in Qt Creator on my PC (very infrequent). It was just an uninitialized variable (just forgot it, my bad), which should be initialized with nullptr.
Does Qt run any kind of supervising script in the background, trying to prevent errors because of uninitialized variables? Well that sounds strange to me (since there is nothing runtime interpreted), but I really can't explain, why it almost always crashed on the notebook (now it doesn't anymore), but only sometimes on my PC, which is probably caused by the device performance since the OS is the same and no other running background software should be interrupting anything. -
No, there are no such scripts. Qt is a C++ framework and it follow its rules. You can use static analysers that will give you warnings about that kind of errors.
As for why it did work better on one computer that the other: sheer luck.