dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #20682
Re: [Bug 702372] Re: BlockMatrix and deleted matrices
On Thursday January 13 2011 23:41:26 Joachim Haga wrote:
> I understand there is a larger issue here. In the meantime, Johan's fix
> (which just keeps the submatrices referenced on the python level) is
> sufficient to remove the crash. Or mine, but Johan's has the distinct
> advantage of being already committed :)
I guess you are right! Sorry for that ;)
> Be aware that there is a memory leak in Block* if "owner" is set on the
> constructor and "set(...)" is later called, but that's probably not very
> important.
Ok, I think the best fix is the one that Garth started out on, using
shared_ptrs. But there are some issues as all objects inheriting from
GenericTensor then needs to be stored using shared_ptr in Python. This mostly
works out of the box, but we probably need to construct director typemaps or
add some shared_ptr<GenericFoo> arguments to director classes, as SWIG wont
handle these correctly.
On the TODO list!
Johan
--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/702372
Title:
BlockMatrix and deleted matrices
Status in DOLFIN:
New
Bug description:
The following code crashes, unless "del A" is commented out. I don't
know the memory handling strategy in dolfin, (boost::shared_ptr is
used in some places, but not consistently?) but attached is a patch
which at least removes the crash by making private copies of the
matrices (and vectors in BlockVectors).
from dolfin import *
mesh = UnitSquare(4, 4)
V = FunctionSpace(mesh, "CG", 1)
u,v = TrialFunction(V), TestFunction(V)
a = u*v*dx
AA = BlockMatrix(1,1)
A = assemble(a)
AA[0, 0] = A
del A
print AA[0,0]
References