matplotlib/matplotlib — pull request #2558 by tacaswell (2013-10-29 18:40:44+00:00)
Title: fixes issue #2556

Fixes it in two ways:

1) changes the closure of `on_dpi` to be over a weakref, not `self`
2) cleans up the call back when the quiver is removed

This should be a reasonable test:

```
X,Y = meshgrid( arange(0,2*pi,.04),arange(0,2*pi,.04) )
U = cos(X)
V = sin(Y)

fig = figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
Q = ax.quiver( U, V)
ttX = Q.X
print "ttx: ", sys.getrefcount(ttX)
print "Q:", sys.getrefcount(Q)

Q.remove()
print "ttx: ", sys.getrefcount(ttX)
print "Q: ", sys.getrefcount(Q)

del Q
print "ttx: ", sys.getrefcount(ttX)
assert sys.getrefcount(ttX) == 2
```

This SO question was helpful: http://stackoverflow.com/questions/10874499/understanding-reference-count-of-class-variable