Regular malloc/free in CS

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
konst
Posts: 30
Joined: Sun Sep 17, 2017 7:41 pm

Regular malloc/free in CS

Post 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
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: Regular malloc/free in CS

Post 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
konst
Posts: 30
Joined: Sun Sep 17, 2017 7:41 pm

Re: Regular malloc/free in CS

Post 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
Post Reply