Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
813 views
in Technique[技术] by (71.8m points)

c++ - How do I get QWebView to release threads?

I am creating a lot of QWebViews which each create QThreads. The problem is that I am running out of stack space to create more threads. Therefore, I was wondering if there is a way to clean up existing threads. To be clear, I am not the one creating these threads: Qt creates the threads when I show a QWebView.

Most of the threads (about 400/500) have the exact same stack:

0  ntdll!RtlEnableEarlyCriticalSectionEventCreation C:Windowssystem32
tdll.dll  0   0x770b013d  
1   KERNEL32!GetVolumePathNamesForVolumeNameA       C:Windowssyswow64kernel32.dll    0   0x766d1a2c  
2   USER32!MessageBoxA                              C:Windowssyswow64user32.dll  0   0x74cd086a  
3   QEventDispatcherWin32::processEvents            qeventdispatcher_win.cpp    831 0x69de3948  
4   QEventLoop::processEvents                       qeventloop.cpp  149 0x69dbf0c5  
5   QEventLoop::exec                                qeventloop.cpp  204 0x69dbf223  
6   QThread::exec                                   qthread.cpp 501 0x69cd412b  
7   QThread::run                                    qthread.cpp 568 0x69cd4283  
8   QThreadPrivate::start                           qthread_win.cpp 346 0x69cd54d1  
9   msvcrt!_itow_s                                  C:Windowssyswow64msvcrt.dll  0   0x75401287  
10  msvcrt!_endthreadex                             C:Windowssyswow64msvcrt.dll  0   0x75401328  
11  KERNEL32!BaseCleanupAppcompatCacheSupport       C:Windowssyswow64kernel32.dll    0   0x766d339a  
12  ntdll!RtlpNtSetValueKey                         C:Windowssystem32
tdll.dll   0   0x770c9ef2  
13  ntdll!RtlpNtSetValueKey                         C:Windowssystem32
tdll.dll   0   0x770c9ec5  
14  ??      0       

Is there any way to clean them up?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since I realized that the thread was allocated for the NetworkManager, I created a global NetworkManager instance and set it to the NetworkAccessManager of every QWebView. This allowed it to reuse the same group of threads for all of the pages and thus doesnt leave many threads laying around.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...