Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

memory leakage problem

Zhanghong_T_
Novice
374 Views

Dear all,

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:

https://software.intel.com/en-us/forums/intel-inspector-xe/topic/606912#comment-1856671

 

could anyone help me to take a look at it?

Thanks,

Tang Laoya

 

0 Kudos
4 Replies
Evgueni_P_Intel
Employee
374 Views

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.

Evgueni.

0 Kudos
Zhanghong_T_
Novice
374 Views

Dear Evgueni,

Thank you very much for your kindly reply. I added the line 

call  mkl_thread_free_buffers()

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'?

Thanks,

Tang Laoya

0 Kudos
Zhanghong_T_
Novice
374 Views

Dear Evgueni,

The problem is solved. I should use the function 

mkl_free_buffers

you suggested instead of

mkl_thread_free_buffers

What is the difference between these two functions? The first one is a general one that include the memory by all threads?

Thanks,

Tang Laoya

 

0 Kudos
Evgueni_P_Intel
Employee
374 Views

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

Evgueni.

0 Kudos
Reply