Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
870 Views

Memory leaks in OpenCL host

I work in big project with OpenCL part. 

In cyclic data processing many calls of OpenCL functions leaves memory leaks, common memory size of program in Program Manager grows and grows, speed is slower and slower... 

All our call to malloc() (and other memory allocation routines) have a corresponding free(). 

I use "Diagnostic Tools" / "Memory Usage" from Visual Studio 2015-2017. 

After each cycle in debuggable program I make snapshot, him shows +180, +130,+80 new allocated blocks in comparison with previous snapshot. 

If I see all new allocated blocks, all have "Undetermined type" and mainly stored call stack from us to "alteracl_icd.dll" and to "ntdll.dll", size of block 7400 bytes. I try many versions of "OpenCL.lib" / "OpenCL.dll" -- leaks is leaved. 

This leaks visual appears in calls to "clFinish()", "clEnqueueReadBuffer()", "clEnqueueNDRangeKernel()", "clEnqueueTask()", "clEnqueueWriteBuffer()" -- all queue functions. Is it possible to free in OpenCL queue work results ? 

In our Altera Cyclone V kit this host program also works 3-5 times and stops on memory shortage. 

May be it a lack in Altera libs or our bug ?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
24 Views

Are you using OpenCL events? Pretty much all OpenCL object also have their associated memory overhead and respective reelase function. You might want to look into the "clRelease" family of functions.

Altera_Forum
Honored Contributor I
24 Views

Thank You, HRZ ! 

An events returning from queue functions and "malloced" inside OpenCL.dll by 7400 bytes, was not released. 

Big Thanks ! 

 

P.S. May be Altera make in their OpenCL SDK a function returning statistic about all allocated objects, what need to be released ?
Reply