Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.
3058 Discussions

A memory leak occurs when decoding with D3D11 using OneVPL's sample_decode.

kohshinToku
Novice
1,111 Views

Hi.

 

I'm using sample_decode of legacy source for oneVPL .

When I decode H.265 file by D3D11,  I discovered that a memory leak occurs.

Please see the attached image.

 
Looking at the memory snapshot, it appears that there is a memory leak in CD3D11Device::RenderFrame().
 

Here, in order to read h.265 files endlessly, the source code is changed as follows.

I also attach sample_decode.exe built in debug mode. Please unzip the zip file.

Execution method :

sample_decode h265 -r -fps 30 -d3d11 -i C:\content\cars_320x240.h265

 

---------------------------------------------------------------------

mfxStatus CSmplBitstreamReader::ReadNextFrame(mfxBitstream* pBS) {
    if (!m_bInited)
        return MFX_ERR_NOT_INITIALIZED;
 
    MSDK_CHECK_POINTER(pBS, MFX_ERR_NULL_PTR);
 
    // Not enough memory to read new chunk of data
    if (pBS->MaxLength == pBS->DataLength)
        return MFX_ERR_NOT_ENOUGH_BUFFER;
 
    memmove(pBS->Data, pBS->Data + pBS->DataOffset, pBS->DataLength);
    pBS->DataOffset = 0;
    mfxU32 nBytesRead =
        (mfxU32)fread(pBS->Data + pBS->DataLength, 1, pBS->MaxLength - pBS->DataLength, m_fSource);
 
    CHECK_SET_EOS(pBS);
 
    if (0 == nBytesRead) {
        // I added source.
fseek(m_fSource, 0, SEEK_SET);
nBytesRead = (mfxU32)fread(pBS->Data + pBS->DataLength, 1, pBS->MaxLength - pBS->DataLength, m_fSource);
//        return MFX_ERR_MORE_DATA;
    }
 
    pBS->DataLength += nBytesRead;
 
    return MFX_ERR_NONE;
}
---------------------------------------------------------------------
 

 

I found a thread like below. This seems to be the same phenomenon I'm encountering, and it looks like the problem has already been resolved, but the sample source code doesn't seem to have been updated. I also checked the Media SDK code, but it didn't seem to have improved.

 

GPU memory leak with MSDK using D3D11 for rendering (sample_decode) - Intel Community

 

Could you please tell me how to modify the source code in order to resolve this issue?

 

My environment is as follows.

11th Gen Intel(R) Core(TM) i5-11500 @ 2.70GHz 2.71 GHz

Driver version:  31.0.101.4826

Windows 11 Pro 22H2

0 Kudos
5 Replies
AlekhyaV_Intel
Moderator
1,048 Views

Hi,


Thank you for posting in Intel Communities. Thanks for sharing all this information with us. We are trying to triage your issue further. To understand your issue further, please share your complete VS project file.


Regards,

Alekhya


kohshinToku
Novice
1,010 Views

Hi

 

Thank you for reply.

 

I'll send you my project.

 

1. Open oneVPL\_build\vpl.sln.

2. Debug sample_decode. Fix the content file path of command arguments for your enviroment.

 

h265 -r -d3d11 -fps 30 -i C:\work\oneVPL-master\examples\content\cars_320x240.h265

 

When you run it, the video of cars passing by will loop forever.
The important thing at this time is that the memory is increasing rapidly in CD3D11Device::RenderFrame(), as attached in the image of the first post.

 

This program I only modified to loop since I didn't have a long h.265-like content file. If you have a long content file, you can quickly check it with regular sample_decode.

 

Regards.

0 Kudos
kohshinToku
Novice
934 Views

Hi.

 

Has there been any progress on this matter? We look forward to your response.

 

Regards.

0 Kudos
AlekhyaV_Intel
Moderator
880 Views

Hi,


We apologize for the delay.


We could see a hike in memory usage with time. We have approached the dev team to find out whether this is an expected behaviour as the program which you provided is continuously decoding, whereas, the default program sample_decode.exe terminates after a definite time.


We will get back to you once we get an update.


Regards,

Alekhya


kohshinToku
Novice
226 Views

Hi.

 

Has there been any progress on this matter? We look forward to your response.

 

Regards.

0 Kudos
Reply