<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QTimer handle leak from inside Qt?]]></title><description><![CDATA[<p dir="auto">Hi. The software I'm working on (using Qt 5.5) crashed recently and I cannot figure out why. The latest log output suggested the event loop was under a lot of stress but running.</p>
<p dir="auto">The error message from the main thread "QEventDispatcherWin32::registerTimer: Failed to create a timer (The current process has used all of its system allowance of handles for Window Manager objects.)" is printed every 500usec to the log handler. It is unknown where it began, I cannot reproduce it or know how it started.</p>
<p dir="auto">The user after about 20 minutes called abort on the Windows message "window is not responding".</p>
<p dir="auto">Something has begun leaking handles while creating timer object probably as fast as possible (the 500usec delta is probably the slowdown due to the error message log handler call). I examined every "new QTimer" and every "QTimer::singleShot" in the source code: nowhere is this created in a loop, in a recursion or in code called repeatedly like this.</p>
<p dir="auto">This is probably a though guess but are there any qt constructs which implicitly create QTimer object / handles which might help identify what's get called here?</p>
<p dir="auto">I first suggested this might be for some reason too many C++11 calls to QThreadLoop using QtConcurrent::run ...but only handles with the maximum amount of active worker threads are actually consumed.</p>
<p dir="auto">Any insight on what might be wrong here? Thank you!</p>
]]></description><link>https://forum.qt.io/topic/98792/qtimer-handle-leak-from-inside-qt</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 01:39:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/98792.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Jan 2019 09:33:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTimer handle leak from inside Qt? on Thu, 31 Jan 2019 10:33:30 GMT]]></title><description><![CDATA[<p dir="auto">Thank you!</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/506370">QTimer handle leak from inside Qt?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/magnus.ni">@<bdi>magnus.ni</bdi></a><br />
There seem to be two possibilities:</p>
<ul>
<li>Despite what you say, your code is somehow creating many timers (e.g. via slots).  Are you freeing the <code>QTimer</code>s when you're done with them?  If you are only using <code>QTimer::singleShot</code>, do you need those instances, could you just use the static version?</li>
</ul>
</blockquote>
<p dir="auto">I'm very seldom explicitly create timers on the heap and almost any of those are single members of a class and bound to the lifetime of the owning class.<br />
I didn't find any ownership problems or recursive slot mechanisms here. When I need single shot I almost always use the static version.</p>
<blockquote>
<ul>
<li>As e.g. <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="https://forum.qt.io/topic/54438/solved-qt-5-4-1-qtimer-using-up-all-handles-for-window-manager-objects">https://forum.qt.io/topic/54438/solved-qt-5-4-1-qtimer-using-up-all-handles-for-window-manager-objects</a>, it may not be the <code>QTimer</code> itself which is being repeatedly created.  The error message could just indicate that you are using up too many Windows handles in general, e.g. from widgets or whatever else in your code.  (In that link it turned out the OP was creating multiple <code>QNetworkAccessManager</code>s --- not saying that's you, but could be anything.)</li>
</ul>
</blockquote>
<p dir="auto">I've read the thread but didn't use the <code>QNetworkAccessManager</code> or something familiar. I've seached the large codebase for any obvious <code>QTimer</code> misusages but without being able to reproduce the issue. But any idea why this might have  implicitly occurred are most welcome since I already watched any QTimer construction in the code for possible side effects like this.</p>
<p dir="auto">Thank you very much</p>
]]></description><link>https://forum.qt.io/post/508597</link><guid isPermaLink="true">https://forum.qt.io/post/508597</guid><dc:creator><![CDATA[magnus.ni]]></dc:creator><pubDate>Thu, 31 Jan 2019 10:33:30 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer handle leak from inside Qt? on Thu, 31 Jan 2019 10:22:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/koahnig">@<bdi>koahnig</bdi></a> said in <a href="/post/506365">QTimer handle leak from inside Qt?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/magnus.ni">@<bdi>magnus.ni</bdi></a></p>
<p dir="auto">Hi and welcome to devnet forum</p>
<p dir="auto">This is merely a user's forum. Your question is probably better suited in the <a href="https://lists.qt-project.org/listinfo/development" target="_blank" rel="noopener noreferrer nofollow ugc">developer's mailing</a> list.</p>
<p dir="auto">Also your Qt version is fairly old. Can't you update to more recent versions? We have already version 5.12.</p>
</blockquote>
<p dir="auto">Thank you very much. I'm afraid this won't be possible. Maybe we can switch to 5.6 in the nearest future (since we're stuck to msvc2010 and 5.6 is the latest build supporting it)</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dheerendra">@<bdi>dheerendra</bdi></a> said in <a href="/post/506390">QTimer handle leak from inside Qt?</a>:</p>
<blockquote>
<p dir="auto">If the process is running you can get the details of handles which are open. Either use process explorer or sone other tool to see the handle details. It is possible that timer error just a manifestation of some other issue.</p>
</blockquote>
<p dir="auto">Thank you. This might be possible. But I myself cannot reproduce the issue or have seen it live.</p>
]]></description><link>https://forum.qt.io/post/508594</link><guid isPermaLink="true">https://forum.qt.io/post/508594</guid><dc:creator><![CDATA[magnus.ni]]></dc:creator><pubDate>Thu, 31 Jan 2019 10:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer handle leak from inside Qt? on Tue, 22 Jan 2019 11:16:40 GMT]]></title><description><![CDATA[<p dir="auto">If the process is running you can get the details of handles which are open. Either use process explorer or sone other tool to see the handle details. It is possible that timer error just a manifestation of some other issue.</p>
]]></description><link>https://forum.qt.io/post/506390</link><guid isPermaLink="true">https://forum.qt.io/post/506390</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Tue, 22 Jan 2019 11:16:40 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer handle leak from inside Qt? on Tue, 22 Jan 2019 10:25:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/magnus.ni">@<bdi>magnus.ni</bdi></a><br />
There seem to be two possibilities:</p>
<ul>
<li>
<p dir="auto">Despite what you say, your code is somehow creating many timers (e.g. via slots).  Are you freeing the <code>QTimer</code>s when you're done with them?  If you are only using <code>QTimer::singleShot</code>, do you need those instances, could you just use the static version?</p>
</li>
<li>
<p dir="auto">As e.g. <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="https://forum.qt.io/topic/54438/solved-qt-5-4-1-qtimer-using-up-all-handles-for-window-manager-objects">https://forum.qt.io/topic/54438/solved-qt-5-4-1-qtimer-using-up-all-handles-for-window-manager-objects</a>, it may not be the <code>QTimer</code> itself which is being repeatedly created.  The error message could just indicate that you are using up too many Windows handles in general, e.g. from widgets or whatever else in your code.  (In that link it turned out the OP was creating multiple <code>QNetworkAccessManager</code>s --- not saying that's you, but could be anything.)</p>
</li>
</ul>
]]></description><link>https://forum.qt.io/post/506370</link><guid isPermaLink="true">https://forum.qt.io/post/506370</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 22 Jan 2019 10:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer handle leak from inside Qt? on Tue, 22 Jan 2019 10:00:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/magnus.ni">@<bdi>magnus.ni</bdi></a></p>
<p dir="auto">Hi and welcome to devnet forum</p>
<p dir="auto">This is merely a user's forum. Your question is probably better suited in the <a href="https://lists.qt-project.org/listinfo/development" target="_blank" rel="noopener noreferrer nofollow ugc">developer's mailing</a> list.</p>
<p dir="auto">Also your Qt version is fairly old. Can't you update to more recent versions? We have already version 5.12.</p>
]]></description><link>https://forum.qt.io/post/506365</link><guid isPermaLink="true">https://forum.qt.io/post/506365</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Tue, 22 Jan 2019 10:00:28 GMT</pubDate></item></channel></rss>