← Back to team overview

dolfin team mailing list archive

Re: [Bug 702372] Re: BlockMatrix and deleted matrices

 

I guess you mean that all the actuall la backend objects use shared_ptr. The 
thing is that these are mostly not exposed to Python. What I mean is that we 
do not have a shared_ptr interface for the GeneriFoo objects. 

Any method or object taking a GenericFoo expects a reference. We could 
duplicate the interface to also include shared_ptr version of GenericFoo 
methods, like we have for Function and FunctionSpace.


Johan

On Thursday January 13 2011 11:06:51 Garth Wells wrote:
> Most (or almost most) of the linear algebra backends use shared
> pointers, and they all should use shared pointers. It shouldn't be a big
> deal to fix this since the most complicated (PETSc and Epetra) already
> use shared pointers (which is particularly neat, since a customised
> destructor for shared pointers calls the necessary PETSc/Epetra
> functions to clean up).
> 
> I think that the Python interface respects the shared pointers. What I
> don't know is exactly what 'del' does to the object A.
> 
> I would like to see DOLFIN be free of plain pointers - it's just a
> source of trouble.

-- 
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