dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23337
Re: [Bug 783857] Re: uBLASSparseMatrix data deleted when object goes out of scope
Hi,
On Wed, May 18, 2011 at 10:39 AM, Garth Wells <783857@xxxxxxxxxxxxxxxxxx> wrote:
> What we could do is add a 'deep copy' option. Perhaps we shouldn't even
> expose the shallow copy in Python since we can't make it const. Changing
> the data would screw up the backend. Would a deep copy work for your
> application?
Having the shallow copy available is very useful, especially if you're
dealing with large matrices and want to avoid copies. Of course having
"real" refcounting would be better, but owing to the apparent
difficulty of implementing that I'm happy as long as it is clearly
documented!
Not sure if having a deep copy option is _that_ useful, considering
how easy it is to do it yourself with the numpy array copy() method?
--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/783857
Title:
uBLASSparseMatrix data deleted when object goes out of scope
Status in DOLFIN:
New
Bug description:
This bug is similar to https://bugs.launchpad.net/dolfin/+bug/747273
The following code produces the output:
0.0333333333333
1.8218374251e-316
I.e. after deleting the uBLASSparseMatrix object the data members are
freed even though there are other references to the data.
from dolfin import *
mesh = UnitTetrahedron()
V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 1)
u = TrialFunction(V)
v = TestFunction(V)
m = inner(v,u)*dx
M = uBLASSparseMatrix()
assemble(m, tensor=M)
row,col,data = M.data()
print data[0]
del M
import gc
gc.collect()
print data[0]
References