Search code examples
c++qtstackqthread

Stack size in QThread


What is the maximal default stack size when using QThread in QT5 and C++? I have a QVector in my thread and I am calling myvector.append() method, and I`m interested how big my vector can be. I found uint QThread::stackSize() const method which returns Stack size, but only if it was previously changed by method setStackSize(), but what is the default Stack Size?


Solution

  • The stack size only plays are role if you are compiling a 32 bit application and you're allocating the storage for your buffer explicitly on the stack. Just using an automatic QVector or std::vector instance doesn't allocate any large buffers on the stack - you'd need to use a custom allocator for that.

    IIRC in 64 bit applications, the memory is laid out such that you won't ever run out of stack space for any reasonable number of threads.