Possible memory leak in dolfin
Issue #451
closed
When running the C++ poisson demo (http://fenicsproject.org/documentation/dolfin/1.5.0/cpp/demo/documented/poisson/cpp/documentation.html) through valgrind the ouput shows some lost memory.
Poisson.ufl
element = FiniteElement("Lagrange", triangle, 1)
u = TrialFunction(element)
v = TestFunction(element)
f = Coefficient(element)
g = Coefficient(element)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds
main.cpp
#include <dolfin.h>
#include "Poisson.h"
using namespace dolfin;
// Source term (right-hand side)
class Source : public Expression
{
void eval(Array<double>& values, const Array<double>& x) const
{
double dx = x[0] - 0.5;
double dy = x[1] - 0.5;
values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02);
}
};
// Normal derivative (Neumann boundary condition)
class dUdN : public Expression
{
void eval(Array<double>& values, const Array<double>& x) const
{
values[0] = sin(5*x[0]);
}
};
// Sub domain for Dirichlet boundary condition
class DirichletBoundary : public SubDomain
{
bool inside(const Array<double>& x, bool on_boundary) const
{
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS;
}
};
int main()
{
// Create mesh and function space
UnitSquareMesh mesh(32, 32);
Poisson::FunctionSpace V(mesh);
// Define boundary condition
Constant u0(0.0);
DirichletBoundary boundary;
DirichletBC bc(V, u0, boundary);
// Define variational forms
Poisson::BilinearForm a(V, V);
Poisson::LinearForm L(V);
Source f;
dUdN g;
L.f = f;
L.g = g;
// Compute solution
Function u(V);
solve(a == L, u, bc);
// Save solution in VTK format
File file("poisson.pvd");
file << u;
// Plot solution
plot(u);
interactive();
return 0;
}
command
valgrind --tool=memcheck --leak-check=yes --log-file=valgrind.log ./main
Please find attached the valgrind output.
Comments (3)
-
-
reporter Oh, I had completely forgotten about that. I'm so very sorry for wasting your time! I guess we can close this.
Have a nice evening!
Mattia
-
reporter - changed status to closed
- Log in to comment
Valgrind + OpenMPI = big mess.
See http://www.open-mpi.org/faq/?category=debugging#valgrind_clean