Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138861

`QRhiResourceUpdateBatch` leaks memory if submitted via `beginOffscreenFrame`

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.9.3, 6.10.0 Beta3, 6.11.0 FF
    • 6.7.3, 6.9.1
    • Qt RHI
    • None
    • macOS, Windows
    • 5860933a6 (dev), dc73b80e2 (6.10), 35bf60eff (6.9)

      updating a QRhiBuffer via QRhiResourceUpdateBatch::updateDynamicBuffer

       

      std::unique_ptr<QRhiBuffer> buffer(rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 1024));
      
      for (int k = 0; k < 10000000; k++) {
        auto ru = renderer.resourceUpdateBatch();
        for (int i = 0; i < 10; i++) {
          ru->updateDynamicBuffer(buffer.get(), 0, sizeof(int), &i);
          ru->updateDynamicBuffer(buffer.get(), 256, sizeof(int), &i);
          ru->updateDynamicBuffer(buffer.get(), 512, sizeof(int), &i);
        }
        renderer.enqueueResourceUpdateBatch();
      }

       

      and then submitting these updates via `beginOffscreenFrame`

       

      void Renderer::enqueueResourceUpdateBatch() {
        QRhiCommandBuffer* cb;
        rhi->beginOffscreenFrame(&cb);
        cb->resourceUpdate(m_currentResourceUpdateBatch);
        rhi->endOffscreenFrame(); 
      }

      Leads to a memory leak.

      The problem seems to come from `QRhiResourceUpdateBatchPrivate::BufferOp::changeToDynamicUpdate` which call `op->data.assign` where `d->ref == 3`. I don't know what is keep some refs which cause this memory leak !

       

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lagocs Laszlo Agocs
            r2d3 David Geldreich
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change