<?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[Memory leak while using QOpenglWidget]]></title><description><![CDATA[<p dir="auto">I am testing a very minimal OpenGL setup using QOpenGLWidget in Qt 6.10 on Windows (MSVC 2022, 64-bit).<br />
Even with a completely empty paintGL(), my application’s RAM usage increases continuously every time the widget repaints.</p>
<p dir="auto">I am trying to understand whether this is:</p>
<p dir="auto">a Qt issue,</p>
<p dir="auto">an OpenGL context / event loop issue, or</p>
<p dir="auto">a NVIDIA driver leak (Threaded Optimization?).</p>
<p dir="auto">When i disable Threaded Optimization in the nvidia settings ,  the leak dissappears.</p>
<pre><code>class GLWidget : public QOpenGLWidget
{
    Q_OBJECT
public:
    explicit GLWidget(QWidget* parent = nullptr);
    void initializeGL() override;
    void paintGL() override;
    void resizeGL(int w, int h) override;

protected:
    void resizeEvent(QResizeEvent* event) override;

private:
    QTimer timer;
};

///////////////////////////////////////////////////////////////////////////////////////

</code></pre>
<pre><code>GLWidget::GLWidget(QWidget* parent) : QOpenGLWidget(parent)
{
    QSurfaceFormat fmt;
    fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    fmt.setProfile(QSurfaceFormat::CoreProfile);
    fmt.setVersion(4, 5);
    QSurfaceFormat::setDefaultFormat(fmt);

    connect(&amp;timer, &amp;QTimer::timeout, this, [this]() {
        update();
    });

    timer.setTimerType(Qt::PreciseTimer);
    timer.setInterval(0); // repaint as fast as possible
    timer.start();
}

void GLWidget::initializeGL()
{
    // nothing here
}

void GLWidget::resizeGL(int w, int h)
{
    glViewport(0, 0, w, h);
}

void GLWidget::paintGL()
{
    // EMPTY on purpose
    // glClearColor(0,0,0,1);
    // glClear(GL_COLOR_BUFFER_BIT);
}
</code></pre>
<pre><code>
</code></pre>
]]></description><link>https://forum.qt.io/topic/163727/memory-leak-while-using-qopenglwidget</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 01:56:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/163727.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Nov 2025 07:01:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Thu, 20 Nov 2025 19:20:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/summit">@<bdi>summit</bdi></a> Then it's an NVIDIA problem.</p>
]]></description><link>https://forum.qt.io/post/833824</link><guid isPermaLink="true">https://forum.qt.io/post/833824</guid><dc:creator><![CDATA[Axel Spoerl]]></dc:creator><pubDate>Thu, 20 Nov 2025 19:20:41 GMT</pubDate></item><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Mon, 17 Nov 2025 10:29:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> This issue only occurs on workstation systems (in my case, an HP Z2 with an RTX A4000) and does not happen on laptops. I believe this may be due to the two systems using different branches of the NVIDIA driver. If i disable Threaded Optimization on the nvidia card then no leak happens. Also Drivers after 560XX.</p>
]]></description><link>https://forum.qt.io/post/833697</link><guid isPermaLink="true">https://forum.qt.io/post/833697</guid><dc:creator><![CDATA[summit]]></dc:creator><pubDate>Mon, 17 Nov 2025 10:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Mon, 17 Nov 2025 05:01:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/axel-spoerl">@<bdi>Axel-Spoerl</bdi></a>  The memory keeps on increasing till the time system goes out of resource and the application crashes , but when i disable Threaded Optimization in Nvidia driver the same application does not increase the RAM.</p>
]]></description><link>https://forum.qt.io/post/833696</link><guid isPermaLink="true">https://forum.qt.io/post/833696</guid><dc:creator><![CDATA[summit]]></dc:creator><pubDate>Mon, 17 Nov 2025 05:01:56 GMT</pubDate></item><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Sun, 16 Nov 2025 20:49:39 GMT]]></title><description><![CDATA[<p dir="auto">Related to <a href="https://bugreports.qt.io/browse/QTBUG-105886" target="_blank" rel="noopener noreferrer nofollow ugc">https://bugreports.qt.io/browse/QTBUG-105886</a> ? Can't reproduce it on my system so I blame the graphics driver.</p>
]]></description><link>https://forum.qt.io/post/833690</link><guid isPermaLink="true">https://forum.qt.io/post/833690</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sun, 16 Nov 2025 20:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Sun, 16 Nov 2025 14:00:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/summit">@<bdi>summit</bdi></a> I think the problem is with your Timer because it is calling paintGL() constantly. In fact   paintGL() Renders the OpenGL scene and should be called whenever the widget needs to be updated and not each time. I believe that each Rendering will use a part of the RAM and when you do that without freeing it the RAM will continue to Increase. You might consider calling a new Constructor of the widget to free the memory but it is just an hypothesis.</p>
]]></description><link>https://forum.qt.io/post/833676</link><guid isPermaLink="true">https://forum.qt.io/post/833676</guid><dc:creator><![CDATA[Ronel_qtmaster]]></dc:creator><pubDate>Sun, 16 Nov 2025 14:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Memory leak while using QOpenglWidget on Sun, 16 Nov 2025 12:30:18 GMT]]></title><description><![CDATA[<p dir="auto">An application consuming RAM doesn't necessarily mean there is a memory leak at all.<br />
In your case, I believe there is no leak.</p>
<p dir="auto">One reason for increasing memory allocation is the Qt Backing Store. That can cause memory allocation if the a <code>QOpenGlWidget</code> is frequently resized. I can't say whether this is the case here, because the actual code causing the resizing/updating isn't shown. In any case: It's expected behaviour and not a memory leak: The memory is freed when the widget is deleted (provided that the class inheriting from it handles destruction well).</p>
<p dir="auto">Another likely cause can be the actual GPU driver. Some drivers defer freeing resources to whatever happens earlier: Context destruction or memory shortage.</p>
]]></description><link>https://forum.qt.io/post/833675</link><guid isPermaLink="true">https://forum.qt.io/post/833675</guid><dc:creator><![CDATA[Axel Spoerl]]></dc:creator><pubDate>Sun, 16 Nov 2025 12:30:18 GMT</pubDate></item></channel></rss>