Hi Greg,
Actually, it turns out that using tuples for stripcharting (which is what
I am doing) is more cumbersome than just using the vectors. The vectors
have the nice feature that making a change to the vectors makes a change
in the graph, so for stripcharts that update every 5 seconds, it has been
easier for me to just use a vector than to make tuples and create and
delete lines every time.
Ike
On Fri, 2 May 2003, Greg McFarlane wrote:
> Ike,
>
> You do not even need to use Pmw.Blt.Vector at all. I generally use
> normal python lists to create the data arrays and convert them to
> tuples using tuple() when passing to bar_create() or line_create()
> methods of Pmw.Blt.Graph.
>
> # 
> import Pmw
> graph = Pmw.Blt.Graph()
> graph.pack()
> xdata = []
> ydata = []
> for i in range(100):
> xdata.append(i  50)
> ydata.append((i  50) * (i  50))
> graph.line_create('smile', xdata = tuple(xdata), ydata = tuple(ydata))
> graph.line_create('lefteye', xdata = (30,), ydata = (4000,))
> graph.line_create('righteye', xdata = (30,), ydata = (4000,))
> # 
>
> Greg
>
> On Wed 30 Apr 2003 at 09:18:50AM 0500, Ike Hall wrote:
> > Hi all,
> >
> > A few weeks ago I posted asking if anyone else saw the memory leak I saw in
> > Pmw.Blt.Graph(). After doing a bit more playing with sample code, and some
> > method hunting, I found that the memory leak actually exists in
> > Pmw.Blt.Vector and is a known bug in BLT. (apparently patches are comming)
> > But, there is a way aound this.
> >
> > Generally, according to sample code on the Pmw website, Vectors are to be
> > treated *almost* the same as lists (at least that is my impression) so that
> > if you have a line with a vector (or 2 vectors) defining the points on the
> > line, one can just modify the values, or append values on the end or remove
> > them or whatever, the same as on would for a python list. However, doing
> > any of these is the cause of the memory leak. There is an alternative,
> > which is a bit more CPU intensive, but if one is graphing lots of data (as I
> > was when I discovered this) the memory problem goes away. the trick is to
> > listify the vector by using the command list(vector) and making
> > modifications to the data in the list object you create, then using
> > Pmw.Blt.Vector.set(list) to 'set' the vector to the data in the list.
> >
> > Example:
> >
> > Old way:
> >
> > vector=Pmw.Blt.Vector()
> > #creation
> > for i in range(10):
> > vector.append(i) #just putting incremental numbers in the
> > vector...doing this alot causes mem probs
> >
> > #updating
> > for i in range(len(vector)):
> > vector[i]=i+1 #this method of updating also causes problems
> >
> >
> > New way:
> >
> > vector=Pmw.Blt.Vector()
> > #creation
> > a=[]
> > for i in range(10):
> > a.append(i)
> > vector.set(a)
> >
> > #updating
> > a=list(vector)
> > for i in range(len(a)):
> > a[i]=a+1
> > vector.set(a)
> >
> > and voilia, memory leak problem goes away.
> >
> >
> >
> >
> >
> > 
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Pmwgeneral mailing list
> > Pmwgeneral@...
> > https://lists.sourceforge.net/lists/listinfo/pmwgeneral
>
>

