Community
cancel
Showing results for 
Search instead for 
Did you mean: 
dirk
Beginner
43 Views

ippiMalloc and friends

Hello,

is there any benefit in using ippiMalloc and there frieds ippMalloc?

The rational behind this question is, that I had problems using static variables that run ippiFree upon application exit (on windows). All ippMalloc functions seem to allocate there buffers on a separate windows heap, e.g the ipps domain will use a different heap than the ippi domain. The heaps will be destructed upon exit of the library. Since the destrutcion of the global variables is not guaranteed, my ippiFree call was executed after the ippi heap was destructed and resulted in a memory access violation.

Additionally this private heap will also not show up in the windows standard memory leak reporting. So I can't catch missing ippFree calls.

And finally I want to "wrap" all image formats into a single class. calling the different versions of ippiMalloc is equivalent with calling the ippMalloc and the specific caluclated size. But as said before, ippiMalloc uses a different heap than the ippMalloc, and there is no general purpose function for ippiMalloc.

Naturally you can use any buffer for the ipp functions. My question is more wether there is any benefit of using the correct functions.

Best regards
Dirk
0 Kudos
2 Replies
Vladimir_Dudnik
Employee
43 Views

Hello Dirk,

as you probably know, the modern processors can read/write data faster when accessing aligned memory address. The advantage of IPP memory allocation functions is that they provide you with properly aligned memory block to speedup your furter access to that memory.

There is no issues related to using IPP memory functions when you stricly and carefully watch for matching memory allocation and deallocation functions. For example, when you allocate memory with ippsMalloc function then you have to delete that block with ippsFree function. The same is true for ippiMalloc or ippMalloc.

And funally, IPP functions does not require that memory should be allocated only with IPP functions. You also may use CRT malloc or any other memory manager API. In that case you have to care about alignment by yourself if you want to maximise calculation speed.

Regards,
Vladimir

Vladimir_Dudnik
Employee
43 Views

Hi Dirk,

If you have global static object which allocates memory with ippiMalloc that should be ok to deallocate that memory with ippiFree function in its destructor.

If you allocate memory with ippMalloc but deallocate with ippiFree - there is an issue.

If you want to work with Bitmap memory directly, you may allocate it with appropriate Win32 functions and than call IPP functions on that data to process.

I think, it is not necessary toput header and pixel data in one contiguous memory block. You may keep them separately.

Regards,
Vladimir