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

DFTFwd_RToPack causes memory leak

Kadir_Kirtac
Beginner
779 Views
Hi, I am using ippiDFTFwd_RToPack_32f_C1 for Fourier transform. When the function is called, it adds about 600K extra memory (almost 1 image size) usage for a 4-channel 424x330 image. I dont see any memory leak when I use ippiFFTFwd_RToPack_32f_C1 for images having width and height of powers of 2.

My Intel IPP version is compxe_ia32_2011.1.127 . I develop using Visual Studio 2008.

Best regards.
0 Kudos
6 Replies
Ying_H_Intel
Employee
779 Views
Hi Kadir,

Thanks for the reports. do you have a piece ofcode to show how do you call the functions and how the memory leak was dectected ?a test case to show the problem may be helpful. You may submit it by private if the test case is confidential.


Best Regards,
Ying
0 Kudos
Chao_Y_Intel
Moderator
779 Views
Hi, please find the expert comment:

Both DFT and FFT use the same mechanism if parameter pBuffer is NULL both allocate and free required memory buffer internally. To disable internal allocation the customer should use GetBufferSize function, allocate required buffer externally and provide this pointer as pBuffer. If he sees any memory leak he should provide a reproducible example of code.

Thanks,
Chao
0 Kudos
Kadir_Kirtac
Beginner
779 Views
Hello, I attach a source code and the input image I used.

Before calling the function, I start Windows Task Manager (of Win XP SP3) and observe that the memory usage of my application is 46.724K (about 46MB), and just after calling the function (before deallocations) the usage raises to 47.848K (about 47MB).

[bash]		int width = 512;
		int height = 512;

		int src32FFTstep;
		Ipp32f* pSrcFFT32 = ippiMalloc_32f_C1(width, height, &src32FFTstep);

		IppiSize srcRoiSize = {width, height};

		IppStatus sts;

		int flag = IPP_FFT_DIV_INV_BY_N;

		int FFTBufferSize;

		IppiDFTSpec_R_32f *DFTSpec = 0;  
		Ipp8u *buffer = 0;

		sts = ippiDFTInitAlloc_R_32f(&DFTSpec, srcRoiSize, flag,
			ippAlgHintAccurate );

		ippiDFTGetBufSize_R_32f(DFTSpec, &FFTBufferSize); 

		buffer = ippsMalloc_8u(FFTBufferSize);

		ippiDFTFwd_RToPack_32f_C1R(pSrc32, src32step,
			pSrcFFT32, src32FFTstep, DFTSpec, buffer); 

		ippiDFTFree_R_32f(DFTSpec); 
		ippsFree(buffer); [/bash]

For the above code, the pSrc32 variable contains the 8u to 32f converted version of the input image.


Best regards.
0 Kudos
Ying_H_Intel
Employee
779 Views
Hi Kadir,

In original post, you mentioned, the memoryincrease when 424x330 image, doesn't see the problem when width and height of powers of 2. But in attached code, the width and height is 512. Do you mean both of szie will incurmemory increasing, right?

I guess, the memory consumptionare not memory leak, but occupied by OpenMP threads. You may know, Some of IPP functionare threaded by OpenMP threads,including the one: ippiDFTFwd_RToPack_32f_C1R.mulitple threads will be started when callthe firstthreaded functionsand stay in memory untill program end. So you may see the memory usage increaseduring thethreaded function call.

Could you please add the below code beforeother IPP function callandtell theresult?
// Print the version of ipp being used
const IppLibraryVersion* lib = ippiGetLibVersion();
printf("%s %s %d.%d.%d.%d\n", lib->Name, lib->Version,lib->major, lib->minor, lib->majorBuild, lib->build);
int nThds;
ippGetNumThreads(&nThds);
printf("IPP num of thread is %d\n", nThds);

Also please tryippSetNumThreads(1)before other IPP functioncall and check if there are memory increase ?

Regards
Ying
0 Kudos
Kadir_Kirtac
Beginner
779 Views
Hello, yes, DFT function increase memory for both of the 424x330 and 512x512 sizes. I observed that FFT function does not increase memory for the 512x512 image

I have tried what you suggested as follows,

[bash]		int width = 512;
		int height = 512;

		int src32step;
		Ipp32f* pSrc32 = ippiMalloc_32f_C1(width, height, &src32step);
		ippsCopy_32f(inputImage, pSrc32, width*height);

		int src32FFTstep;
		Ipp32f* pSrcFFT32 = ippiMalloc_32f_C1(width, height, &src32FFTstep);

		IppiSize srcRoiSize = {width, height};

		IppStatus sts;

		int flag = IPP_FFT_DIV_INV_BY_N;

		int FFTBufferSize;

		IppiDFTSpec_R_32f *DFTSpec = 0;  
		Ipp8u *buffer = 0;

		sts = ippiDFTInitAlloc_R_32f(&DFTSpec, srcRoiSize, flag,
			ippAlgHintAccurate );

		ippiDFTGetBufSize_R_32f(DFTSpec, &FFTBufferSize); 

		buffer = ippsMalloc_8u(FFTBufferSize);

		FILE * pFile;
		fopen_s(&pFile,"dft_report.txt","wt");

		const IppLibraryVersion* lib = ippiGetLibVersion();
		fprintf(pFile, "%s %s %d.%d.%d.%dn", lib->Name, lib->Version,lib->major, lib->minor, lib->majorBuild, lib->build);
		int nThds;
		ippGetNumThreads(&nThds);
		fprintf(pFile, "IPP num of thread is %dn", nThds);

		ippSetNumThreads(1);

		ippGetNumThreads(&nThds);
		fprintf(pFile, "IPP num of thread after ippSetNumThreads(1) is %dn", nThds);

		fclose (pFile);

		ippiDFTFwd_RToPack_32f_C1R(pSrc32, src32step,
			pSrcFFT32, src32FFTstep, DFTSpec, buffer); 

		ippiDFTFree_R_32f(DFTSpec); 
		ippsFree(buffer);
[/bash]

The result is

[bash]ippip8-7.0.dll 7.0 build 205.23 7.0.205.1020
IPP num of thread is 4
IPP num of thread after ippSetNumThreads(1) is 1[/bash]

But setting num of threads to 1 did not solve the memory increase problem. The problem in my side is, I call dft function many times during my application. I apply an image processing algorithm which is based on a parameter setting controlled by the user. So, as the user changes the parameter, dft is run again and again, and so the memory size always increases..
0 Kudos
Ying_H_Intel
Employee
779 Views
Hi Kadir, So interesting, I try the code, but add initilization with dst, Ipp32f* pSrcFFT32 = ippiMalloc_32f_C1(width, height, &src32FFTstep); ippiSet_32f_C1R(0.0, pSrcFFT32, src32FFTstep, srcRoiSize); Then there is not memory change in task manager. May you try ? Regards, Ying
0 Kudos
Reply