Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: sparse.linalg: make *Inv objects in arpack garbage-collectable by refcount #3968

Merged
merged 2 commits into from
Sep 9, 2014

Conversation

pv
Copy link
Member

@pv pv commented Sep 4, 2014

Setting self._method = self._method by passing self._method to
LinearOperator causes a reference cycle in the various inverse
operators. self._method = Class._method works.

The reference cycle prevents these objects from being GC'd immediately
by refcount. Since these objects hold large amounts of data, it's easy
to run out of memory before cyclic GC runs, if eigs/eigsh is called in a
tight loop, so it's best to not create refcycles here.

[Issue spotted from a post on stackoverflow --- causes eigs/eigsh to appear to leak memory in a tight for loop raising MemoryErrors. The issue can be worked around by calling gc.collect(), but it's best to not create unnecessary refcycles in the first place.]

…y refcount

Setting self._method = self._method by passing self._method to
LinearOperator causes a reference cycle in the various inverse
operators. self._method = Class._method works.

The reference cycle prevents these objects from being GC'd immediately
by refcount.  Since these objects hold large amounts of data, it's easy
to run out of memory before cyclic GC runs, if eigs/eigsh is called in a
tight loop, so it's best to not create refcycles here.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 3b59de1 on pv:arpack-cyclefix into 706aa57 on scipy:master.

@pv
Copy link
Member Author

pv commented Sep 9, 2014

Fixes gh-3362

@argriffing
Copy link
Contributor

I don't completely understand the scipy linear operator interface, but this looks OK to me so I'll merge.

argriffing added a commit that referenced this pull request Sep 9, 2014
BUG: sparse.linalg: make *Inv objects in arpack garbage-collectable by refcount
@argriffing argriffing merged commit 113bebf into scipy:master Sep 9, 2014
@argriffing
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants