Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak caused by CFHD_PrepareToEncode (Windows only?) #51

Open
bluetarpmedia opened this issue Nov 9, 2021 · 0 comments
Open

Memory leak caused by CFHD_PrepareToEncode (Windows only?) #51

bluetarpmedia opened this issue Nov 9, 2021 · 0 comments

Comments

@bluetarpmedia
Copy link

bluetarpmedia commented Nov 9, 2021

There appears to be a memory leak when calling CFHD_PrepareToEncode. I've only tested on Windows 10.

I first observed this in some unit tests for my encoder (the unit test calls _CrtDumpMemoryLeaks), so to try and confirm the problem, I tried an infinite loop of creating an encoder, calling PrepareToEncode, and closing the encoder, to see how the process VM usage grows over time.

Using 8fd6bba from 'master' (9 Nov 21), build the solution with VS 2019 x64, and then insert the following at the very start of main() in TestCFHD.cpp

while (true)
{
    CFHD_EncoderRef enc = nullptr;
    CFHD_Error res = CFHD_OpenEncoder(&enc, nullptr);
    if (res != CFHD_ERROR_OKAY)
        return res;

    res = CFHD_PrepareToEncode(
        enc,
        320,
        160,
        CFHD_PIXEL_FORMAT_RG24,
        CFHD_ENCODED_FORMAT_YUV_422,
        CFHD_ENCODING_FLAGS_NONE,
        CFHD_ENCODING_QUALITY_DEFAULT);
    if (res != CFHD_ERROR_OKAY)
        return res;

    CFHD_CloseEncoder(enc);
}

Watch the process memory usage in something like Windows Task Manager.

The VM usage grows sharply with smaller resolutions (like 160x80, 320x160, etc) but much slower with higher resolutions.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant