Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.15.8
-
None
Description
When a QVideoFrame is constructed using a QImage, it creates a QImageVideoBufferPrivate object. Internally QImageVideoBufferPrivate calls the `QImage::bits()` function, twice. The documentation for this function states the following:
> Note that QImage uses implicit data sharing. This function performs a deep copy of the shared pixel data, thus ensuring that this QImage is the only one using the current return value.
QImageVideoBufferPrivate never cleans up these copies, resulting in a memory leak.
In my use case this was quite sizeable, as each frame was about 24 MB, and the program would crash to an allocation failure in a couple of minutes. For the moment I working around this by subclassing QAbstractVideoBuffer and passing an instance my custom class to QVideoFrame.