Hi list!
I asked a couple of questions about a memory leak about a month ago and Gael
provided a fix. Except that after adding a vector field to the mix, his fix
stopped working, so I am back at a loss as to why mayavi leaks memory when I
clear the pipeline.
Therefore, I took another approach: I do not clear the pipeline, but replace
the scalar arrays instead:
S=mlab.gcf().children[0]
ds=S.mlab_source.dataset
for i in range(ds.point_data.number_of_arrays-1,-1,-1):
if (ds.point_data.get_array(i) is not None):
ds.point_data.remove_array(ds.point_data.get_array(i).name)
S.mlab_source.set(scalars=phi3.T)
ds.point_data.scalars.name = 'phi3'
nid2 = ds.point_data.add_array(phi2.ravel())
ds.point_data.get_array(nid2).name = "phi2"
nid1 = ds.point_data.add_array(phi1.ravel())
ds.point_data.get_array(nid1).name = "phi1"
This fixes the memory leak, even when the vector field is added to the mix.
However, it creates another: for some reason, if I replace the data with the
same data, I get a different picture. It is as if one of the axes (x, I think)
had been inverted in the process.
Is this the correct way to replace arrays and if it is, why does this happen?
The data in the new arrays is the same as in the old ones, as compared by
numpy.allclose(old.to_array(), new.to_array()), so the replacing works at
least that far.
Also, after replacing, the S.mlab_source.dataset has some extra traits, namely
actual_memory_size, bounds, cell_data and center. Which is strange is that the
origin trait has changed: before replacing, it is array([ 1., 1., 1.]) and
after array([-2.95, -2.95, -2.95]). For what it's worth, the *latter* is what
I would expect to have since I do S.origin=[-2.95, -2.95, -2.95] initially.
So, I'd be happy if someone could shed some light on this.
Cheers,
Juha
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users