CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Bugs (
-   -   Memory leak in OpenFOAM? (

marupio September 21, 2010 09:52

Memory leak in OpenFOAM?
It looks like OpenFOAM has a memory leak.

I ran scalarTransportFoam on the swirlTest tutorial, set the timestep to 0.1, end time to 1000, write interval 1. As it ran I watched the process monitor. Memory use climbed slowly and steadily from 400 mb to 500 mb before I finally stopped the simulation. Why would this be?

This happened on an old revision of 1.5-dev, as well as 1.6. I don't have 1.7 installed yet.

I started looking into this because my custom solver seems to have a bad case of the memory leaks.

Any ideas?

marupio September 21, 2010 12:37

I have confirmed this is a legitimate memory leak. It is case directory dependent - I can only duplicate it using the old swirlTest tutorial from OpenFOAM-1.5. (It doesn't happen for pitzDaily.)

I have isolated it to:


l_r_mcglashan September 22, 2010 04:25

Did you try running it through valgrind? If your OF is compiled for debugging it will even tell you the offending code lines:

valgrind --tool=memcheck --leak-check=yes scalarTransportFoam

l_r_mcglashan September 22, 2010 04:34

So scalarTransportFoam on pitzDaily is fine. There appears to be a small leak in bubbleFoam however.

deepsterblue September 22, 2010 09:11

Interesting. Since you mention that you've isolated the problem to runTime.write(), I'm curious to see whether the leak depends on the write mode (ascii/binary) and/or precision.

marupio September 22, 2010 09:35

It might not be present in OF1.7.x - Henry ran my test case and valgrind reported nothing for him.

It's just the old swirlTest tutorial from 1.5... if no one else can duplicate it, it's my machine.

I also found the source of the (big) leak in my custom solver - you can't use a single fvMeshSubset object to produce more than one submesh, or else you lose a mesh-sized chunk of memory.

mattijs September 28, 2010 09:15

We've finally got a proper bug reporting system :-)
Please report any OpenFOAM bugs on



marupio September 28, 2010 11:37

Yes I have been informed, and am now registered with Mantis. We should put a sticky announcement at the top of this forum.

bruxellois October 14, 2010 12:49


Could you help me please?

check this if you dont mind.

Thanks in advance.


All times are GMT -4. The time now is 02:49.