From: Jonathan B. <jbr...@ea...> - 2005-12-20 06:27:07
|
On Mon, 2005-12-19 at 18:48 -0500, Jeremy Sachs wrote: > I'm working on a program that draws a continuous curve, and when the > number of points on that curve exceeds 1024, a new curve is drawn at > the end of the old curve. > > How many 1024-point curves can visual python manage before crashing? Here goes a long answer to a simple question... It should go until you run out of physical RAM. For N points, the maximum memory usage is 2*3*sizeof(double)*2*N, or 48 bytes per point, but it can be as few as 24 bytes per point. Curve objects preallocate storage for up to 2x the total number of points in order to make curve.append() work fast. When using .append(), the total allocated storage is approximated by min( 256, 2^X) for incrementally increasing values of X (it is actually slightly more than this). If you precalculate the curve's pos or color array rather than simply append() to it, the storage will be enough for exactly 2x the size of the initial array (doubling as needed for subsequent appends). You don't normally see this extra allocation since curve.pos is actually a slice into the real pos array. For your usage pattern, the extra space will be small, and total storage will be a pinch larger than 24 bytes per point. There's also some per-object overhead which should be pretty small compared to the storage required for the points themselves. Therefore, per-object memory usage should be about 24-25K per 1024-point curve segment. As far as rendering goes, curves with zero radius (the default) are rendered much much faster than thick curves. HTH, -Jonathan |