# MKL_FreeBuffers

Frees memory buffers.

## Syntax

void MKL_FreeBuffers(void)

## Description

The MKL_FreeBuffers function frees the memory allocated by the Intel MKL Memory Manager. The Memory Manager allocates new buffers if no free buffers are currently available. Call MKL_FreeBuffers() to free all memory buffers and to avoid memory leaking on completion of work with the Intel MKL functions, that is, after the last call of an Intel MKL function from your application.

See Intel® MKL User’s Guide for details.

## MKL_FreeBuffers Usage with FFT Functions

----------------------------------------------------------------------------------------------

DFTI_DESCRIPTOR *hand1, *hand2;

void MKL_FreeBuffers(void);

. . . . . .

/* Using MKL FFT */

Status = DftiCreateDescriptor(&hand1, DFTI_SINGLE, DFTI_COMPLEX, dim, m1);

Status = DftiCommitDescriptor(hand1);

Status = DftiComputeForward(hand1, s_array1);

. . . . . .

Status = DftiCreateDescriptor(&hand2, DFTI_SINGLE, DFTI_COMPLEX, dim, m2);

Status = DftiCommitDescriptor(hand2);

. . . . . .

Status = DftiFreeDescriptor(&hand1);

/* Do not call MKL_FreeBuffers() here as the hand2 descriptor will be destroyed! */

. . . . . .

Status = DftiComputeBackward(hand2, s_array2));

Status = DftiFreeDescriptor(&hand2);

/* Here user finishes the MKL FFT usage */

/* Memory leak will be triggered by any memory control tool */

/* Use MKL_FreeBuffers() to avoid memory leaking */

MKL_FreeBuffers();

----------------------------------------------------------------------------------------------

If the memory space is sufficient, use MKL_FreeBuffers after the last call of the MKL functions. Otherwise, a drop in performance can occur due to reallocation of buffers for the subsequent MKL functions.

### Warning

For FFT calls, do not use MKL_FreeBuffers between DftiCreateDescriptor`(hand)` and `DftiFreeDescriptor(&hand)`.

Parent topic: Memory Functions