Memory leak in Python Expression interface
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
DOLFIN |
Fix Released
|
High
|
Unassigned |
Bug Description
The below code leads to a memory leak (I see a leak over about 2MB over 90s). The leak is related to the Expression. If I comment out the call to
eval(
from
dolfin:
I don't detect a leak.
------
from dolfin import *
parameters[
parameters[
class MyExpression(
def eval(self, values, x):
if x[0] < DOLFIN_EPS:
mesh = UnitSquare(32, 32)
for t in xrange(20000):
for level in xrange(100):
V = FunctionSpace(mesh, "CG", 1)
v = TestFunction(V)
u = Function(V)
u0 = Function(V)
f = MyExpression(
L = v*(u-u0)*dx + v*f*ds
b = assemble(L)
print "----"
Changed in dolfin: | |
status: | Fix Committed → Fix Released |
Here's another solver that leaks. It doesn't use Expressions.
from dolfin import *
class MyProblem( NonlinearProble m):
NonlinearProbl em.__init_ _(self)
assemble( self.L, tensor=b)
assemble( self.a, tensor=A)
def __init__(self, a, L):
self.L = L
self.a = a
def F(self, b, x):
def J(self, A, x):
mesh = UnitSquare(8, 8, "crossed") Douglas- Marini" , 1) ace([BDM, DG, DG])
BDM = FunctionSpace(mesh, "Brezzi-
DG = FunctionSpace(mesh, "Discontinuous Lagrange", 0)
mixed_space = MixedFunctionSp
V = TestFunction( mixed_space) mixed_space) mixed_space) mixed_space)
dU = TrialFunction(
U = Function(
U0 = Function(
v, q, r = split(V)
u, p, s = split(U)
u0, p0, s0 = split(U0)
L = inner(v, u)*dx - div(v)*p*dx + v[0]*dx + q*div(u)*dx + r*(s - s0)*dx
a = derivative(L, U, dU)
for level0 in xrange(1000):
for level in xrange(10):
A = Matrix();
b = Vector();
# This does not appear to leak
problem. F(b, U.vector())
problem. J(A, U.vector())
problem = MyProblem(a, L)
# This does leak
#solver. solve(problem, U.vector())
#solver = NewtonSolver()
# This does leak (goes through call-back to Python)
lu = LUSolver()
lu.solve(A, U.vector(), b)
print "End inner loop"