如何增加一个线程在Qt的堆栈大小 - QThread :: setStackSize()似乎不工作? [英] How to increase stack size for a thread in Qt - QThread::setStackSize() seems not to work?

查看:6211
本文介绍了如何增加一个线程在Qt的堆栈大小 - QThread :: setStackSize()似乎不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从问题: SQLite运行一个500行的批量插入时堆栈溢出:为什么?,我需要增加Qt中某个线程的堆栈大小。

From the question: SQLite stack overflow when running a bulk insert with 500 rows: why?, I need to increase the stack size for a certain thread in Qt.

这是跨平台,但我最初开始尝试让它在Windows上工作。

I would like this to be cross-platform, but I am initially starting by trying to get it working on Windows.

不幸的是,我没有试图成功增加堆栈大小有问题的线程。 (我通过添加代码来评估当前堆栈大小(请参见上面的链接),并观察到堆栈溢出崩溃发生在1 MB,这不反映堆栈大小,我想设置)测量堆栈大小。)

Unfortunately, nothing I have tried to do successfully increases the stack size for the thread in question. (I measure the stack size by adding code to evaluate the current stack size (see link above), and observing that a stack overflow crash occurs at 1 MB, which does not reflect the stack size I am trying to set.)

我已经尝试过以下操作:

I have tried the following things:

在Qt的 .pro 文件:

QMAKE_CXXFLAGS += /F 32000000
QMAKE_LFLAGS   += /STACK:32000000

在源代码中, QThread :: start()函数在线程上被调用:

In the source code, the line before the QThread::start() function is called on the thread:

work_queue_manager_thread.setStackSize(static_cast<uint>(stackSize));

(其中 work_queue_manager_thread $ c> QThread 实例, stackSize 为32000000)。

(where work_queue_manager_thread is the QThread instance, and stackSize is 32000000).

上面的两个尝试个人,我已经尝试过他们在一起。结果是相同的:堆栈大小保持在1 MB的有问题的线程。它不反映我想要的堆栈大小。我无法为我的Qt线程设置堆栈大小。

I have tried both of the above attempts individually, and I have tried them together. The result is the same: the stack size remains at 1 MB for the thread in question. It does not reflect my desired stack size. I am unable to set the stack size for my Qt thread.

我如何实际上将Qt线程的堆栈大小设置为32000000 -

How do I actually set the stack size for a Qt thread to 32000000 - and in a way that works across Windows and OS X?

推荐答案

找出问题工作中指示的QMAKE标志。

Turns out the QMAKE flags indicated in the question work.

但是,使用Qt Creator,执行全部清除并重建不能工作,标志。相反,必须删除整个Debug / Release文件夹,然后执行重建。然后它工作。

However, using Qt Creator, performing a Clean All and rebuild does not work to pick up the new flags. Instead, the entire Debug/Release folder must be deleted, and then a rebuild performed. Then it works.

但是标志只适用于Windows - 我可能会更新这个答案,当我确定OS X标志,希望很快。

But the flags only work for Windows - I may update this answer when I determine the OS X flags, hopefully shortly.

无论如何,标志的工作方式如下。

Nonetheless, the flags work as indicated.

这篇关于如何增加一个线程在Qt的堆栈大小 - QThread :: setStackSize()似乎不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆