ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.01k stars 407 forks source link

`SimdRecursiveBilateralFilter` memory leak #237

Closed LiuPeiqiCN closed 1 year ago

LiuPeiqiCN commented 1 year ago

Code:

cv::Mat src = cv::imread("lena.png");

float sigmaSpatial = 0.2;
float sigmaRange = 0.2;

cv::Mat dst(src.size(), src.type());

for (size_t i = 0; i < 10000; i++)
{
    void* filter = SimdRecursiveBilateralFilterInit(src.cols, src.rows, src.channels(), &sigmaSpatial, &sigmaRange, SimdRecursiveBilateralFilterFast);

    if (filter != NULL)
    {
        SimdRecursiveBilateralFilterRun(filter, src.data, src.step1(), dst.data, dst.step1());
        delete filter;
    }
}

Memory growth is very fast.

ermig1979 commented 1 year ago

Hi!

In the description of function SimdRecursiveBilateralFilterInit there is
a note that filter context must be released with using of function SimdRelease.

LiuPeiqiCN commented 1 year ago

Thank you very much.

My mistake. I have seen the document, but my eyes didn't notice this. Sorry to bother you.