Page 1 of 1

Regular malloc/free in CS

Posted: Thu Oct 11, 2018 1:15 pm
by konst
Hello,

I am wondering is it obligatory to use BFT_MALLOC/BFT_FREE in the user functions (boundary conditions and initilization)? Or it is possible to use usual malloc/free?

I am wondering about that because I am using regular malloc/free and looks like I have some memory leaks, but not sure where it comes from.

Best regards,
Konstantin

Re: Regular malloc/free in CS

Posted: Thu Oct 11, 2018 9:39 pm
by Yvan Fournier
Hello,

You can use malloc/free as long as you do not mix with BFT_MALLOC/BFT_FREE.

BFT_MALLOC and BFT_FREE add instrumentation : if you define a file name in the CS_MEM_LOG environment variable (which you must then export in your environment), you will have a trace and leak report... The simplest way to do this is to add:
export CS_MEM_LOG=mem_log
in the runcase file, before the "code_saturne run" line.

Best regards,

Yvan

Re: Regular malloc/free in CS

Posted: Mon Oct 15, 2018 11:14 am
by konst
Thanks a lot for your reply, Yvan.

At the end valgrind and your advice help me to find the memory leaks in my code.

Best regards,
Konstantin