Memory Woes

Greg Dunn news at gregdunn.org.zzz
Fri Feb 28 17:27:58 CET 2003


>Is your canvas object of known, and maybe predetermined dimensions?

Yes

> If so, why not just keep a list of points or vectors and *move* them in
> rotation, re-using objects that have scrolled off the left, rather than
> constantly creating new objects?  This would probably be faster too.

Brilliant idea!  I tried this this morning and it worked like a charm... my
memory faucet is now leak free (or close enough, anyway).  My code looks a
bit hacked now, but I should be able to clean that up :-)

> By the way, if you keep scrolling the canvas left (or any other direction
for
> that matter) won't you eventually hit the dimensions limit for canvas
> objects?

I'm not actually scrolling the canvas, just the points sitting on it.  When
I plot a new point, every point is shifted to the left one unit and the new
point is plotted at the far right side of the canvas.  Points are recycled,
as per your suggestion, when they reach x = 0.

> I obviously don't know what hardware you're running on, but I found
Tkinter to
> work faster than I expected on my PII/300, admittedly with a reasonable
> graphics card.

It seems to run very smoothly on my PII/500... even when deleting/redrawing
every line as suggested by Bill

Thanks for the great suggestions, guys!

--Greg







More information about the Python-list mailing list