Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

sample_encode memory leak #3038

@okfujian

Description

@okfujian

os info:
ubuntu 20.04 5.15.0-56-generic

vainfo:
error: can't connect to X server!
libva info: VA-API version 1.15.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.15 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.4.4 (7bde93561)
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc

11th Gen Intel(R) Core(TM) i7-1165G7

When using sample_encode, I found memory leak, I just modified the main function of sample_encode,
Sleep for 50s before the main function exits, and during the sleep,
you can see that the memory has not been released through top commad.

./sample_encode h265 -i test.yuv -o test.h265 -w 1920 -h 1080 -dstw 1920 -dsth 1080 -b 10000 -f 60 -hw -async 1 -u speed

`
int TestImpl(void *parg)
{
std::unique_ptr pPipeline;

mfxStatus sts = MFX_ERR_NONE; // return value check
sInputParams Params = *((sInputParams*)parg);


MSDK_CHECK_PARSE_RESULT(sts, MFX_ERR_NONE, 1);

// Choosing which pipeline to use
pPipeline.reset(CreatePipeline(Params));

MSDK_CHECK_POINTER(pPipeline.get(), MFX_ERR_MEMORY_ALLOC);

if (MVC_ENABLED & Params.MVC_flags)
{
    pPipeline->SetNumView(Params.numViews);
}

sts = pPipeline->Init(&Params);
MSDK_CHECK_STATUS(sts, "pPipeline->Init failed");

pPipeline->PrintInfo();

msdk_printf(MSDK_STRING("Processing started\n"));

if (pPipeline->CaptureStartV4L2Pipeline() != MFX_ERR_NONE)
{
    msdk_printf(MSDK_STRING("V4l2 failure terminating the program\n"));
    return 0;
}

for (;;)
{
    sts = pPipeline->Run();

    if (MFX_ERR_DEVICE_LOST == sts || MFX_ERR_DEVICE_FAILED == sts)
    {
        msdk_printf(MSDK_STRING("\nERROR: Hardware device was lost or returned an unexpected error. Recovering...\n"));
        sts = pPipeline->ResetDevice();
        MSDK_CHECK_STATUS(sts, "pPipeline->ResetDevice failed");

        sts = pPipeline->ResetMFXComponents(&Params);
        MSDK_CHECK_STATUS(sts, "pPipeline->ResetMFXComponents failed");
        continue;
    }
    else
    {
        MSDK_CHECK_STATUS(sts, "pPipeline->Run failed");
        break;
    }
}

pPipeline->CaptureStopV4L2Pipeline();

pPipeline->Close();

msdk_printf(MSDK_STRING("\nProcessing finished\n"));
return 0;

}
#if defined(_WIN32) || defined(_WIN64)
int _tmain(int argc, msdk_char *argv[])
#else
int main(int argc, char *argv[])
#endif
{
sInputParams Params = {}; // input parameters from command line

mfxStatus sts = MFX_ERR_NONE; // return value check
 // Parsing Input stream workign with presets
sts = ParseInputString(argv, (mfxU8)argc, &Params);
ModifyParamsUsingPresets(Params);

TestImpl((void*)&Params);
    msdk_printf(MSDK_STRING("\nclose finished\n"));
TestImpl((void*)&Params);
TestImpl((void*)&Params);
TestImpl((void*)&Params);
TestImpl((void*)&Params);

usleep(50*1000*1000);
msdk_printf(MSDK_STRING("\nProcessing finished\n"));

return 0;

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions