View Issue Details

IDProjectCategoryView StatusLast Update
0000814OpenFOAMBugpublic2013-04-10 19:23
Reporterdkokron Assigned Tohenry  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformFedora 18 64-bitOSLinuxOS Version3.8.5-201.fc18.x
Summary0000814: memory leak when using 'fourth' for gradSchemes
DescriptionUsing the 'fourth' option to compute gradients results in a memory leak that consumes all system memory (64GB) in ~25 times steps using my original case (9.5M cells).

System:
Linux xxxxxx 3.8.5-201.fc18.x86_64 #1 SMP Thu Mar 28 21:01:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Compiler:
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.1.1.163 Build 20130313

mpirun --version
mpirun (Open MPI) 1.6.3

OpenFOAM:
2.2.x-2c25eeea8de3

valgrind --version
valgrind-3.8.1
Steps To Reproducecd ~tutorials/incompressible/pisoFoam/les/motorBike/motorBike
Edit system/fvSchemes, change grad(U) to fourth
Edit system/controlDict, change endTime to 5
./Allrun

Rerun simpleFoam under valgrind
mpirun --bysocket --bind-to-core --mca mpi_paffinity_alone 1 -np 8 valgrind --alignment=32 --leak-check=full --track-origins=yes --log-file=simpleFoam5dt.vg simpleFoam -parallel
Additional Informationoutput from valgrind
==22154== 35,464,381 (240 direct, 35,464,141 indirect) bytes in 1 blocks are definitely lost in loss record 1,366 of 1,367
==22154== at 0x4A09361: operator new(unsigned long) (vg_replace_malloc.c:298)
==22154== by 0x686C39B: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:74)
==22154== by 0x4C6C5BE: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==22154== by 0x4C6BB30: Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvcGrad.C:101)
==22154== by 0x50420D3: Foam::incompressible::RASModels::SpalartAllmaras::correct() (SpalartAllmaras.C:433)
==22154== by 0x41A2FD: main (simpleFoam.C:73)
==22154==
==22154== 88,252,416 bytes in 3 blocks are possibly lost in loss record 1,367 of 1,367
==22154== at 0x4A08CE4: operator new[](unsigned long) (vg_replace_malloc.c:363)
==22154== by 0x4C49A45: Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> const&) (List.C:94)
==22154== by 0x686C3FE: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:82)
==22154== by 0x4C6C5BE: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==22154== by 0x4C6BB30: Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvcGrad.C:101)
==22154== by 0x50420D3: Foam::incompressible::RASModels::SpalartAllmaras::correct() (SpalartAllmaras.C:433)
==22154== by 0x41A2FD: main (simpleFoam.C:73)



Output from valgrind using my original case.

==20255== 593,879,832 bytes in 7 blocks are possibly lost in loss record 1,360 of 1,360
==20255== at 0x4A08CE4: operator new[](unsigned long) (vg_replace_malloc.c:363)
==20255== by 0x4C49A45: Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> const&) (List.C:94)
==20255== by 0x686C3FE: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:82)
==20255== by 0x4C6C5BE: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==20255== by 0x4C6BB30: Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvcGrad.C:101)
==20255== by 0x501D5F8: Foam::incompressible::RASModels::kOmegaSST::correct() (kOmegaSST.C:434)
==20255== by 0x41A2FD: main (simpleFoam.C:73)
TagsNo tags attached.

Activities

henry

2013-04-09 22:04

manager   ~0002107

I cannot reproduce the problem here on a smaller case, will also try the motorbike case.

Is your OpenFOAM-2.2.x build up-to-date?
Have you tried with gcc? (I am using gcc and Clang)

dkokron

2013-04-09 22:22

reporter   ~0002108

I did a pull last week, not sure of the exact date. The specific rev is 2.2.x-2c25eeea8de3. I'll do another pull today, rebuild and test again.

I have not tried compiling with GNU compilers yet. I will give it a try.

dkokron

2013-04-10 14:38

reporter   ~0002109

I did a pull yesterday and rebuilt the whole code under GCC using debug. valgrind reports the same issue.

2.2.x-cbf764f7ad01

g++ --version
g++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)

c++DBUG = -ggdb3 -DFULLDEBUG
c++OPT = -O0 -fdefault-inline


trace from motorbike

==2508== 117,670,176 bytes in 4 blocks are possibly lost in loss record 420 of 420
==2508== at 0x4A07CE4: operator new[](unsigned long) (vg_replace_malloc.c:363)
==2508== by 0x4C87AD8: Foam::List<Foam::Tensor<double> >::List(Foam::List<Foam::Tensor<double> > const&) (List.C:94)
==2508== by 0x4C834C2: Foam::Field<Foam::Tensor<double> >::Field(Foam::Field<Foam::Tensor<double> > const&) (Field.C:144)
==2508== by 0x4C8D199: Foam::DimensionedField<Foam::Tensor<double>, Foam::volMesh>::DimensionedField(Foam::IOobject const&, Foam::DimensionedField<Foam::Tensor<double>, Foam::volMesh> const&) (DimensionedField.C:192)
==2508== by 0x4C8AD01: Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> const&) (GeometricField.C:486)
==2508== by 0x65004C4: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:83)
==2508== by 0x4C72451: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==2508== by 0x4C6D62D: Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) (fvcGrad.C:101)
==2508== by 0x4C6967A: Foam::tmp<Foam::GeometricField<Foam::outerProduct<Foam::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::grad<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvcGrad.C:147)
==2508== by 0x5097E34: Foam::incompressible::RASModels::SpalartAllmaras::correct() (SpalartAllmaras.C:405)
==2508== by 0x446CE3: main (simpleFoam.C:65)

henry

2013-04-10 14:43

manager   ~0002110

Can you reproduce the problem on a smaller case e.g. icoFoam running the cavity case?

henry

2013-04-10 16:05

manager   ~0002111

I am unable to reproduce the problem on the tutorials/incompressible/pisoFoam/les/motorBike/motorBike.

dkokron

2013-04-10 17:37

reporter  

fvSolution (1,290 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-06;
        relTol          0;
    }

    U
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance       1e-05;
        relTol          0;
    }
}

PISO
{
    nCorrectors     2;
    nNonOrthogonalCorrectors 0;
    pRefCell        0;
    pRefValue       0;
}

cache
{
    grad(U)         ;
}


// ************************************************************************* //
fvSolution (1,290 bytes)   

dkokron

2013-04-10 17:37

reporter  

fvSchemes (1,424 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default         Euler;
}

gradSchemes
{
    default         Gauss linear;
    grad(U)         fourth;
}

divSchemes
{
    default         none;
    div(phi,U)      bounded Gauss linearUpwindV grad(U);
}

laplacianSchemes
{
    default         none;
    laplacian(nu,U) Gauss linear orthogonal;
    laplacian((1|A(U)),p) Gauss linear orthogonal;
}

interpolationSchemes
{
    default         linear;
    interpolate(HbyA) linear;
}

snGradSchemes
{
    default         orthogonal;
}

fluxRequired
{
    default         no;
    p               ;
}


// ************************************************************************* //
fvSchemes (1,424 bytes)   

dkokron

2013-04-10 17:40

reporter   ~0002112

Last edited: 2013-04-10 17:41

I am able to reproduce the leak using tutorials/incompressible/icoFoam/cavity with the attached fvSchemes and fvSolution. This is the minimum set of changes needed to reproduce the leak in my environment.

==7073== 735,364 (1,344 direct, 734,020 indirect) bytes in 21 blocks are definitely lost in loss record 20 of 22
==7073== at 0x4A08361: operator new(unsigned long) (vg_replace_malloc.c:298)
==7073== by 0x54F6BBA: Foam::zeroGradientFvPatchField<Foam::Tensor<double> >::clone(Foam::DimensionedField<Foam::Tensor<double>, Foam::volMesh> const&) const (zeroGradientFvPatchField.H:133)
==7073== by 0x5562C96: Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricBoundaryField(Foam::DimensionedField<Foam::Tensor<double>, Foam::volMesh> const&, Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField const&) (GeometricBoundaryField.C:359)
==7073== by 0x5561AFC: Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> const&) (GeometricField.C:486)
==7073== by 0x59B04C4: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:83)
==7073== by 0x57BF60F: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==7073== by 0x57C0C17: Foam::linearUpwindV<Foam::Vector<double> >::correction(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (linearUpwindV.C:84)
==7073== by 0x59D9CBC: Foam::fv::gaussConvectionScheme<Foam::Vector<double> >::fvmDiv(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (gaussConvectionScheme.C:103)
==7073== by 0x59E70D3: Foam::fv::boundedConvectionScheme<Foam::Vector<double> >::fvmDiv(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (boundedConvectionScheme.C:77)
==7073== by 0x453C50: Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::div<Foam::Vector<double> >(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) (fvmDiv.C:57)
==7073== by 0x44A8AB: Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::div<Foam::Vector<double> >(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvmDiv.C:83)
==7073== by 0x44523D: main (icoFoam.C:61)
==7073==
==7073== 1,650,582 (11,520 direct, 1,639,062 indirect) bytes in 48 blocks are definitely lost in loss record 21 of 22
==7073== at 0x4A08361: operator new(unsigned long) (vg_replace_malloc.c:298)
==7073== by 0x59B04AF: Foam::fv::fourthGrad<Foam::Vector<double> >::calcGrad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (fourthGrad.C:83)
==7073== by 0x57BF60F: Foam::fv::gradScheme<Foam::Vector<double> >::grad(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) const (gradScheme.C:154)
==7073== by 0x57C0C17: Foam::linearUpwindV<Foam::Vector<double> >::correction(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (linearUpwindV.C:84)
==7073== by 0x59D9CBC: Foam::fv::gaussConvectionScheme<Foam::Vector<double> >::fvmDiv(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (gaussConvectionScheme.C:103)
==7073== by 0x59E70D3: Foam::fv::boundedConvectionScheme<Foam::Vector<double> >::fvmDiv(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) const (boundedConvectionScheme.C:77)
==7073== by 0x453C50: Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::div<Foam::Vector<double> >(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::word const&) (fvmDiv.C:57)
==7073== by 0x44A8AB: Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::div<Foam::Vector<double> >(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) (fvmDiv.C:83)
==7073== by 0x44523D: main (icoFoam.C:61)

henry

2013-04-10 19:23

manager   ~0002113

Thanks for the simpler test setup, this helped pin-point the problem.
Resolved by commit e04af4b8e013fdcc5b11f6e8eca174971a1b22b8

Issue History

Date Modified Username Field Change
2013-04-09 20:43 dkokron New Issue
2013-04-09 22:04 henry Note Added: 0002107
2013-04-09 22:22 dkokron Note Added: 0002108
2013-04-10 14:38 dkokron Note Added: 0002109
2013-04-10 14:43 henry Note Added: 0002110
2013-04-10 16:05 henry Note Added: 0002111
2013-04-10 17:37 dkokron File Added: fvSolution
2013-04-10 17:37 dkokron File Added: fvSchemes
2013-04-10 17:40 dkokron Note Added: 0002112
2013-04-10 17:41 dkokron Note Edited: 0002112
2013-04-10 19:23 henry Note Added: 0002113
2013-04-10 19:23 henry Status new => resolved
2013-04-10 19:23 henry Resolution open => fixed
2013-04-10 19:23 henry Assigned To => henry