Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Memory leak for ipp version 7.0.205

J_T_
Beginner
559 Views

Hi all,

we are using ipp version 7.0.205 in our program. Experiments show that there are some memory leaks. After we fixed all heap-related memory leak and ran IBM Rational Purify, it points to

status = ippiMorphReconstructDilate_8u_C1IR(inMask, imgCols, reconImg, imgCols,roi, pBuffer, ippiNormL1);
            ImageIPPError::checkIppStatus (status, _CRT_WIDE(__FILE__),__LINE__);

Here is the Purify output snip.

Here is the code we were using, which is very close to IPP example in http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch8/functn_MorphReconstructDilate.html

    // Local manual managed resources.
    IppiMorphAdvState *state = NULL;
    Ipp8u *pBuffer = NULL;
    try
    {
        const Ipp8u* inMask = inMaskImg.getData();
        const Ipp8u* inMarker = markerImg.getData();
        Ipp8u* reconImg = outImageMask.getData();

        IppiSize roi = {imgCols, imgRows};
        int imgSize = 0;

        IppiSize msize = {3, 3};  // The structure element size
        Ipp8u mask[3*3] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
        IppiPoint anchor = {msize.width/2, msize.height/2};
    
        //Allocate memory and initialize the structure element
        IppStatus status = ippStsNoErr;
        status = ippiMorphAdvInitAlloc_8u_C1R(&state, roi, mask, msize, anchor);
        ImageIPPError::checkIppStatus (status, _CRT_WIDE(__FILE__),__LINE__);

        // Get the buffer needed for reconstruction
        status = ippiMorphReconstructGetBufferSize_8u_C1(roi, &imgSize);
        ImageIPPError::checkIppStatus (status, _CRT_WIDE(__FILE__),__LINE__);        
        //pBuffer = new Ipp8u[imgSize];
        pBuffer = ippsMalloc_8u(imgSize);

        // Use the marker image to initialize the reconstructed image
        status = ippiCopy_8u_C1R(inMarker, imgCols, reconImg, imgCols, roi);
        ImageIPPError::checkIppStatus (status, _CRT_WIDE(__FILE__),__LINE__);

        // Call reconstruction
        status = ippiMorphReconstructDilate_8u_C1IR(inMask, imgCols, reconImg, imgCols,
                                            roi, pBuffer, ippiNormL1);
        ImageIPPError::checkIppStatus (status, _CRT_WIDE(__FILE__),__LINE__);

        //delete[] pBuffer; pBuffer = NULL;
        ippsFree(pBuffer); pBuffer = NULL;
        ippiMorphAdvFree(state); state = NULL;
    }
    catch (...)
    {
        if (pBuffer != NULL)
        {
            //delete[] pBuffer; pBuffer = NULL;
            ippsFree(pBuffer); pBuffer = NULL;
        }
        if (state != NULL)
        {
            ippiMorphAdvFree(state); state = NULL;
        }
        throw;
    }

Initially, we thought we should NOT use        pBuffer = new Ipp8u[imgSize]. But even after we use pBuffer = ippsMalloc_8u(imgSize), Purify still gave the same memory leak detection.

Any suggestions, comments would be very helpful!!!

Thanks a lot!

0 Kudos
4 Replies
J_T_
Beginner
559 Views

Purify output snip is missing. I have attached the PNG file here.

0 Kudos
Chao_Y_Intel
Moderator
559 Views

Hello,

Can you try to link with non threaded Intel IPP library, and see if there is any error reported?  I see in the attached file, the error reported is to the OpenMP library, we notice similar case before, and openmp may internal maintain some internal buffer, and may take as the memory leak.  If you link with non threading, it will not depend on the openmp.

Thanks,
Chao

0 Kudos
J_T_
Beginner
559 Views

In our product code, we intend to use libiomp because of speed and performance requirement. When you notice similar case before, what other solutions have you tried? Will upgrade to 8.0 solve the issue? Thanks!

0 Kudos
Chao_Y_Intel
Moderator
559 Views

Hi,

Regarding the OpenMP runtime library memory report by some memory checking tools, actually most of them is actually some false positive report. No actually memory is happening there. Some more discussion is here:

http://software.intel.com/en-us/forums/topic/279131

Thanks,
Chao

0 Kudos
Reply