PDA

View Full Version : QThread won't start



Cruz
2nd February 2014, 21:20
Hello! I need help with debugging a thread issue. I wrote a Qt application that collects a large amount of experimental data. Then I start a QThread that runs analytic algorithms on the data and outputs some aggregated results. I have been using it for a while without problems, but now for some reason the thread won't start. Instead, it flips me the bird with:


QThread::start: Failed to create thread (The access code is invalid.)

I noticed that the thread does start when I record a new set with a small amount of data. But it does not with the 1.6 GB data I load from a file. I don't even know where to start. A little help please?

ChrisW67
2nd February 2014, 22:35
You are loading 1.6GB into RAM all at once? Windows I assume. 32-bit or 64-bit application?

Cruz
2nd February 2014, 22:44
Yes, and it fits into my RAM so why bother make it more complicated? Windows 7 and 32-bit application. I reduced the data size to about 700 MB just now and the thread starts again. It seems to be connected to the data size somehow.

ChrisW67
2nd February 2014, 23:16
How is that data loaded? One contiguous lump? Your 32-bit windows process has a maximum memory space of 2 or 3GB (http://msdn.microsoft.com/en-us/library/windows/desktop/aa366778%28v=vs.85%29.aspx#memory_limits) and the largest contiguous lump of that may be (will be) smaller than 1.6GB.

Cruz
2nd February 2014, 23:33
Ah ok I wasn't paying attention to that! But still. The way I load my data is exactly like this:



void State::load()
{
QMutexLocker locker(&mutex);

QList<State> history;

QFile file("data/statehistory.dat");
file.open(QIODevice::ReadOnly);
QDataStream in(&file);

QByteArray ba;
while (!in.atEnd())
{
in >> ba;
history << *(State*)(ba.data());
}

file.close();
}


So it appends into a QList one by one. I believe QList does not need contiguous memory for all objects inside, only for the pointers pointing to them. Is that right? There are roughly 200.000 pointers times 32 bit should be less than 1MB. Also, if I tried to allocate more contiguous space than I'm allowed to, the application should crash with a segfault or something. There is no problem with the loading. Everything still works afterwards, except that the data analyzer thread won't start.