Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Quiver leaks memory when called multiple times #2556

Closed
@markdbenedict

Description

@markdbenedict

I have created quite a nice visualization program using Qt as the interface layer and matplotlib to draw much of the content. I use contour and countourf as well as text and lines and never run into problems with releasing objects. I need to draw many plots to create the input for an animation.

As soon as I start calling Axes.quiver I get leaks. With the size of the dataset it adds up quickly. I am unable to use the animation module due to conflicts with other functionality, and the X,Y values and shapes change between frames so quiver.set_UVC() is of no use to me.

The following code demonstrates the problem with the simple for loop replacing the animation code I would use:

from pylab import *
from numpy import ma
import time


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])
for i in range(90):
    Q = ax.quiver( U, V)
    time.sleep(0.2)

I know this simple snippet isnt drawing to screen (leak becomes worse then).

Q has a sys.getrefcount of 4 so nothing I am able to do seems to get rid of it. Calls to fig and ax clear only reduce the refcount to 2. Telling Q to remove() itself doesnt help.

My code is much more complex than this. I have tried completely replacing the axes objects but that doesnt help. I really am not free to replace the Figure instance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions