Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
qBadAlloc - strange problem
LuGRU last edited by LuGRU
I run into qBadAlloc issue when running my application.
Memory usage was around 800MB so I don't hit 2GB (or something around it) limit in 32bit mode.
Now strange part is:
In background Firefox was running all day, compilation in release mode (FF still in background) and QByteArray crashed on realloc(), then running in debug same story. Tested on another PC - works fine, tested on MacBook - works fine. After that I closed Firefox and rerun debug session again ... from now on application works just fine. Now I don't run into qBadAlloc() issue on this machine.
Can any one explain how this is possible, does another 32bit process (Firefox) could cause this issue to happen?
Thanks for any info.
EDIT: Affected PC - Windows 8.1 64bit Qt 5.4.2 msvc 2010 - compilation in 32bit mode.
Anotehr PC (ok) - Windows 8.1 64bit Qt 5.4.2 msvc 2010 - compilation in 32bit mode.
Mac (ok) - Mac Os X 10.10.3 64bit Qt 5.4.2 - compilation in 64bit mode.
mcosta last edited by
have you tried to Debug your application and verify when and where the crash happens??
Do you have some code to show??
BTW 800MB is a big number!!
I run with debugger that's why I know that application crashes in QByteArray realloc function and when allocating more memory fails it do crash.
This part of code is used to compress data to ZIP file. It's not stream base that's why usage is so high.
But reall question is why same code (nothing was changed) crashed in debug mode and after closing Firefox and again rerunning application in debug mode problem is resolved.
Not only that - in application I do have 2 ways to save file to ZIP and using "other" way did work for large file but when used "first" mode it did crash (didn't crash on other PC with WIn 8.1 / Mac 10.10 - run also in debug mode).
I know that my description is vague but I'm working on large application and I can't go into details here.
Another question - could to much recursive calls cause throw of qBadAlloc() ?
Did you check the available memory on your computer when FireFox was running ?
Yes, there was plenty of free memory.
Also I performed test - closing Firefox and recreating opened tabs - no issue.
Theory - I will need to test this out but I'm suspecting that issue is related to manually set "Virtual Memory" on system.
Tested on other applications (many Firefox tabs, memory intense application) and apps did crash - although in event viewer I don't see any crash related to memory per say but this may be a case here).
How are you modifying the virtual memory handling on your computer ?
Are you increasing or decreasing the available Virtual Memory ?
I tried both - now I cant reproduce issue.
When issue with qBadAlloc() occured virtual was set to "automatic" - so no limitation's issue.
At this point I'm out of ideas. Now application works perfectly fine - with no code change.
Then there's only one answer: gremlins...
Unfortunately no gremlins here, just trolls :D
I run some more test and nothing come up so I can't explain why application do crash for same input data but memory do spikes to much so I'm redesigning some mem intensive parts.
Thanks for the input.