Intel® IPP Memory Function ippMalloc/Free FAQ


Intel® Integrated Performance Primitives (Intel® IPP) is a cross-architecture software library that provides a broad range of library functions for image processing, signal processing, data compression, cryptography, and computer vision, as well as math support routines for such processing capabilities. Intel IPP is optimized for the wide range of Intel microprocessors.

One of the key advantages within Intel IPP is performance coming through highly optimized functions and resource management including memory management. This paper covers the different flavors of those functions in Intel IPP dealing with memory allocation, deallocation, and alignment. After reading this article you should be able to use the correct memory allocation functions for your specific needs. Further documentation on Intel IPP can be found at Intel® Integrated Performance Primitives – Documentation.

What are the Intel® IPP memory functions?

Intel IPP provides easy-to-use functions for pointer alignment, memory allocation and deallocation:




void* ippAlignPtr(void* ptr, int alignBytes);

Aligns a pointer.

Can align to 2/4/8/16/…

void* ippMalloc(int length);

64-byte aligned memory allocation.

Can only free memory with ippFree.

void ippFree(void* ptr);

Free memory allocated by ippMalloc.

Can only free memory allocated by ippMalloc.

Ipp<datatype>* ippsMalloc_<datatype>(int len);

64-byte aligned memory allocation for blocks of 32-bit length and signal elements of different data types.

Limited to memory blocks of up to 2 GB.
Can only free memory with ippsFree.

Ipp<datatype>* ippsMalloc_<datatype>_L(IppSizeL len);Platform-aware 64-byte aligned memory allocation for signal elements of different data types.Available since Intel IPP 2017.
Can only free memory with ippsFree.

void ippsFree(void* ptr);

Free memory allocated by ippsMalloc.

Can only free memory allocated by ippsMalloc.

Ipp<datatype>* ippiMalloc_<mod>(
int widthPixels, int heightPixels,
int* pStepBytes);

64-byte aligned memory allocation for images where every line of the image is padded with zeros.

Limited to memory blocks of up to 2 GB.
Can only free memory with ippiFree.

Ipp<datatype>* ippiMalloc_<mod>_L (IppSizeL widthPixels,
IppSizeL heightPixels,
IppSizeL* pStepBytes);
Platform-aware 64-byte aligned memory allocation for images where every line of the image is padded with zeros.Available since Intel IPP 2017.
Can only free memory with ippiFree.

void ippiFree(void* ptr);

Frees memory allocated by ippiMalloc.

Can only free memory allocated by ippiMalloc.


How are Intel® IPP memory functions different from the standard malloc and free functions?

Intel IPP memory functions align the memory to a 64-byte boundary for optimal performance on Intel® architecture.

How do I call ippsMalloc or ippiMalloc?

Please take a look at the examples in the manual.

void func_malloc(void)
    Ipp8u* pBuf = ippsMalloc_8u(8*sizeof(Ipp8u));
    if (NULL == pBuf)
        // not enough memory

Example 3-2: Using the function ippsMalloc.

ippiMalloc  from Source Code Examples from Intel IPP book* (including the whole example project)

What is the maximum amount of memory that can be allocated by Intel® IPP functions?

We expect that there are no restrictions to the amount of memory that can be allocated except as defined by the the user's operating system and system hardware. For memory allocations beyond 2 GB on 64-bit systems the platform-aware (e.g. ippsMalloc_<datatype>_L, ippiMalloc_<mod>_L) have to be used instead. Those functions are available since Intel IPP 2017. It is good practice to use platform-aware functions.

How do I deallocate memory?

Use the corresponding Intel IPP memory deallocation functions: ippFree, ippsFree and ippiFree. These functions cannot be used to free memory allocated by standard functions like malloc or calloc; nor can the memory allocated by the Intel IPP malloc functions be freed by the standard function free.

What is the advantage of using ipp*Malloc functions?

Intel IPP functions can perform better on aligned data. By calling an ipp*Malloc functions to allocate data, the data is aligned for optimal performance on your Intel processor.

Why should memory be aligned?

Processor pipeline stalls occur when memory is accessed on the cache-line boundary. Alignment of memory buffers is used in order to minimize such occurrences. Please check the Intel® Developer Zone to access Software Optimization Guides for your Intel processor.

How is the image stride or step used when calling ippiMalloc?

Image stride or step is the number of bytes in one row of the image. The ippiMalloc function takes the width and height of the image in pixels as arguments and returns the memory stride in bytes and a pointer to the memory. The size of the memory allocated is not known until after the function call; then it can be calculated as:

memSize = stride * height * numChannels;
  • The function ippiMalloc_8u_C3 first sets the stride to the smallest multiple of 64 that is greater than width * numChannels. Then the function allocates stride * height bytes.
  • The function ippiMalloc_32f_C3, which allocates 32-bit floating-point pixels, sets the stride to the smallest multiple of 64 that is greater than width * numChannels * bytesPerChannel.

Is there any difference between ippMalloc/ippFree() and ippsMalloc/ippsFree() functions?

Basically there is no difference between these functions. Both allocating array of bytes (where for example ippsMalloc_16s allocates array of short integers) and both provide the same alignment for allocated buffer.
It is recommended you use corresponding free functions, ippFree for ippMalloc and ippsFree for all ippsMalloc variants. To get more information about these functions refer to
Intel Integrated Performance Primitives Developer Reference documentation.

Is there any requirement for Intel® IPP functions to use memory only allocated through ippMalloc?

No, Intel IPP functions does not require that memory should be allocated only with Intel 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 maximize calculation speed.


* Other names and brands may be claimed as the property of others.

Microsoft, Windows, and the Windows logo are trademarks, or registered trademarks of Microsoft Corporation in the United States and/or other countries.

Optimization Notice

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804

Copyright © 2002-2016, Intel Corporation. All rights reserved.

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.