On Thu, Dec 09, 2010 at 05:09:37PM +0000, Juha Jäykkä wrote:
> Now, I would have thought that 

> foo=mlab.get_engine().current_scene.scene
> mlab.get_engine().remove_scene(foo)

> would free the memory used by said scene, but it does not. I assume
> that there is a hidden reference to the data somewhere inside
> mayavi/mlab which is not removed by remove_scene, but it seems hopeless
> to find it.

First of all, it seems to me that the right way to close a scene would be
to use the 'close_scene' method of the engine. You can see this by
looking at the source code of the mlab.close function.

If you still have leaks, I suggest that you have a look at the mlab.clf
function that clears a scene:

def clf(figure=None):
    """Clear the current figure.

    You can also supply the figure that you want to clear.
    """
    try:
        if figure is None:
            scene = gcf()
        else:
            scene = figure
        disable_render = scene.scene.disable_render
        scene.scene.disable_render = True
        scene.children[:] = []
        scene._mouse_pick_dispatcher.clear_callbacks()
        scene.scene.disable_render = disable_render
    except AttributeError:
        pass
    gc.collect()

You can see that they are a few calls to make sure that nothing is left
behind. It might even be worth calling clf before closing the scene (you
can use the disable_render flag to avoid extra costly rendering).

> How do properly clean up the pipeline and free all the memory involved?

If the above suggestion doesn't fix the problem, I would need a
minimalistic example that reproduces the problem, as chances are that you
are simply leaving some references lying around to your objects.

HTH,

Gaël

------------------------------------------------------------------------------
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to