[triangle-zpug] why is this using a lot of memory?

Joseph Mack NA3T jmack at wm7d.net
Tue Mar 25 15:23:56 UTC 2008


intervals=10000000 #some large number
height=0
for x in range(0, intervals):
 	height+=x

(I get the same result whether running interactive or from a 
file with the above code)

For a sufficiently large value of "intervals" the program 
exits immediately with a MemoryError. For slightly smaller 
values, the program takes up most of the memory of the 
machine. I would have thought that you'd only be allocating 
a couple of variables. What am I missing? Am I allocating an 
"intervals" number of something, rather than a single 
variable with a large value?

thanks Joe

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!



More information about the triangle-zpug mailing list