qDebug() prevents from crash?
Hello,
I´ve got a strange problem -at least for me :D
My program crashes and when I insert a
- qDegug() << "foo";
Unfortunately, I was not able to write a minimum example, that compiles and shows the same problem.
So just here a few lines from my code, to make you understand my problem:
- for (int i = 0; i < knownPivotFeatures.size(); i++) {
- // qDebug() << "foo";
- if(knownPivotFeatures[i]){
- qDeleteAll(*knownPivotFeatures[i]);
- } else {
- }
- }
where knownPivotFeatures is a QList<QHash<QUuid, MyClass const*>*>.
(Another issue is, that the compiler seems to change the order. I added another qDebug() << “bar”; to the Destructor of MyClass. And first, the “foo“s (more than one ;)) are printed and finally the “bar“s.)
I´m afraid, that the source of my problem(s) is somewhere completely else, but probably, you have an idea, what kind of problem I should look for?
Thank you in advance,
Maria
8 replies
Not without you telling us what platform you’re on. On linux, you could look into valgrind [valgrind.org].
Hello everyone!
I fixed my memory leak and really: The program did not crash any more (it did not crash because the RAM was full, it crashed for any other still unknown reason).
But I´m still curious: How can it be, that the single line “qDebug() << “foo”; prevents my program from crashing?
And is it the compiler optimization, that the “foo“s and “bar“s are not mixed, when I add the “bar” to the destructor?
Thanks a lot,
Maria.
In theory, qDebug() takes some buffer and does something for it that would otherwise make the faulty line address memory that is not usually available.
This explanation is sufficient for me, thank you :)
Valgrind would tell exact reason for that, just use it, since you’re only one who actually has your code.
I´m using Windows and am to lazy to find an equivalent shy
You must log in to post a reply. Not a member yet? Register here!




