[Interest] Default stack size of QThread

Ulf Hermann ulf.hermann at qt.io
Tue Aug 29 09:05:58 CEST 2023


> As we donot set any stack size for QThread and it looks like it runs out 
> of default stack size limit during long running operation. Hence would 
> like to measure the cumulative stack variables used in a thread so as to 
> set stack size of QThread accordingly.

It is possible to measure stack usage, but there is no fun in it. If 
you're willing to use private QtQml API you can call stackProperties() 
as declared in [1] to find an approximation of the stack boundaries. You 
can then compare that with currentStackPointer(), conveniently defined 
in the same file, to get your stack usage.

Mind that it's not really exact. See [2] for the implementation.

[1] 
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/memory/qv4stacklimits_p.h

[2] 
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/memory/qv4stacklimits.cpp

best regards,
Ulf Hermann


More information about the Interest mailing list