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.
3075 Discussions

HW Init/Close Decode Memory leak with MSDK 2013, MSDK 2013 R2

Andrey_K_
Beginner
577 Views

I found that init HW decoding and then closing it, lead to memory leak. I saw ealier posts about leaks, but not sure if it have the same nature.

Here is code to reproduce issue:

[cpp]

static size_t GetProcessHeapSize(){
    auto heap = GetProcessHeap();
    if(!HeapLock(heap)){
        return -1;
    }
    PROCESS_HEAP_ENTRY entry = PROCESS_HEAP_ENTRY();
    size_t size = 0;
    while(HeapWalk(heap, &entry)){
        if(entry.wFlags & PROCESS_HEAP_ENTRY_BUSY){
            size += entry.cbData;
        }
    }
    HeapUnlock(heap);
    return size;
}

static void MemLeak() {
    mfxStatus sts = MFX_ERR_NONE;
    mfxVersion ver = {4, 1};
    mfxSession ses = mfxSession();
    sts = MFXInit(MFX_IMPL_HARDWARE, &ver, &ses); // didn't reveal for software impl
    
    mfxVideoParam cfg = mfxVideoParam();
    cfg.mfx.CodecId = MFX_CODEC_AVC;
    cfg.AsyncDepth = 1;
    sts = MFXVideoDECODE_Init(ses, &cfg); // returns MFX_ERR_INVALID_VIDEO_PARAM
    sts = MFXVideoDECODE_Close(ses); // returns MFX_ERR_NOT_INITIALIZED
    sts = MFXClose(ses);
}

static void MemLeakTest() {
    auto started = GetTickCount();
    auto counter = 0;
    while(true){
        MemLeak();
        auto ellapsed = GetTickCount() - started;
        if(ellapsed > 1000){
            printf("heap size: %d Kb, cnt=%d\n", (int)(GetProcessHeapSize() / 1024), counter);
            started = GetTickCount();
        }
        ++counter;
    }
}

[/cpp]

This issue doesn't depend on whether MFXVideoDECODE_Init was succesfull or not. And it doesn't appear for SW implementation.

sys info:

[plain]

Intel Media SDK System Analyzer (64 bit)


The following versions of Media SDK API are supported by platform/driver:

    Version    Target    Supported    Dec    Enc
    1.0    HW    Yes        X    X
    1.0    SW    Yes        X    X
    1.1    HW    Yes        X    X
    1.1    SW    Yes        X    X
    1.3    HW    Yes        X    X
    1.3    SW    Yes        X    X
    1.4    HW    Yes        X    X
    1.4    SW    Yes        X    X
    1.5    HW    No             
    1.5    SW    Yes        X    X
    1.6    HW    No             
    1.6    SW    Yes        X    X
    1.7    HW    No             
    1.7    SW    Yes        X    X

Graphics Devices:
    Name                                         Version             State
    Intel(R) HD Graphics 3000                    9.17.10.3223        Active

System info:
    CPU:    Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
    OS:    Microsoft Windows 8 Pro
    Arch:    64-bit

Installed Media SDK packages (be patient...processing takes some time):
    Intel® Media SDK 2013 R2 (x64)

[/plain]

It is also reproduced with Intel Media SDK 2013 (x64) in 32 and 64 mode.

Are there any workarounds to prevent these leaks?

BTW why imsdk ver after 1.4 are not support HW acceleration, as I intalled last intel HD graphics (15.28.18) and directx11 is up to date?

0 Kudos
2 Replies
Anthony_P_Intel
Employee
577 Views

Hi,

This appears to be a memory leak in the graphics driver. I'll make sure the driver team is aware of your sighting.

The Intel(R) 2nd Generation Core processors (with Intel(R) HD Graphics 3000 adapters) only support hardware features of (up to) API 1.4.  Newer hardware supports new features.

0 Kudos
skyrec
Beginner
577 Views
Hi, I've tried that piece of source what Andrey provided, but with VPP procedure. The memory leaking I got will faster than only decoding procedure. The following pseudo code is what I took at home, I hope this information will help to you. Regards, skyrec void RepeatProcedure() { mfxVersion ver = {4, 1}; mfxSession ses = mfxSession(); MFXInit(MFX_IMPL_HARDWARE, &ver, ses) // create DirectX11 device and context // CComPtr, CComPtr MFXVideoCORE_SetHandle(MFX_HANDLE_D3D11_DEVICE) MFXVideoCORE_SetFrameAllocator() MFXVideoDECODE_DecodeHeader() MFXVideoDECODE_QueryIOSurf() MFXVideoVPP_QueryIOSurf() // adopts D3D11_MEMORY // allocate surface pool for Decoder // allocate surface pool for VPP MFXVideoDECODE_Init() MFXVideoVPP_Init() do { // retrieve bit-streaming from file MFXVideoDECODE_DecodeFrameAsync() MFXVideoVPP_RunFrameVPPAsync() MFXVideoCORE_SyncOperation() // video rendering } while (true); MFXVideoVPP_Close() MFXVideoDECODE_Close() MFXClose(ses) // release surface pool which used by Decoder // release surface pool which used by VPP } -----8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<---- Intel Media SDK System Analyzer (64 bit) The following versions of Media SDK API are supported by platform/driver: Version Target Supported Dec Enc 1.0 HW Yes X X 1.0 SW Yes X X 1.1 HW Yes X X 1.1 SW Yes X X 1.3 HW Yes X X 1.3 SW Yes X X 1.4 HW Yes X X 1.4 SW Yes X X 1.5 HW Yes X X 1.5 SW Yes X X 1.6 HW Yes X X 1.6 SW Yes X X 1.7 HW No 1.7 SW Yes X X Graphics Devices: Name Version State Intel(R) HD Graphics 4000 9.18.10.3165 Active System info: CPU: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz OS: Microsoft Windows 8 Pro Arch: 64-bit Package: Media SDK 2013 R2 (x64) Intel(R) HD Graphics 4000 9.18.10.3165 Active System info: CPU: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz OS: Microsoft Windows 8 Pro Arch: 64-bit
0 Kudos
Reply