I have a project with multiple times using MKL functions. After tens of times calling my program, the memory usage is larger and large (from initial 100 MB to latter more than 10 GB). So I use the Intel Inspector to check the location of memory leak. However, the Inspector can't find the location from my code but it is in MKL's functions. The original post is here:
could anyone help me to take a look at it?
Hi Tang Laoya,
Could you please call mkl_free_buffers in each thread just before it joins the master thread?
You may also read the MKL documentation about memory management https://software.intel.com/en-us/node/528564.
Thank you very much for your kindly reply. I added the line
at the end of the cycle and before next cycle begin, and then checked the problem again, however, the problems are still here. Where should I place the function 'mkl_thread_free_buffers' and what's mean ' just before it joins the master thread'?
The problem is solved. I should use the function
you suggested instead of
What is the difference between these two functions? The first one is a general one that include the memory by all threads?
Dear Tang Laoya,
A call to mkl_free_buffers frees the memory allocated before this call by all threads spawned by MKL.
A call to mkl_thread_free_buffers frees the memory allocated before this call by the calling thread.
To find the description of these functions, you may have a look at reference manual -> support functions -> memory management here https://software.intel.com/en-us/mkl-reference-manual-for-c