From: Bruce S. <Bru...@nc...> - 2010-05-10 00:45:30
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> This is interesting and may be important. You might be the only user of Visual who routinely runs a program for "a day or so", which would explain why no one else has reported a problem.<br> <br> Is it possible that you could winnow down to a much simpler test case that still demonstrates the problem?<br> <br> As to the status of numpy, on the Windows download page at vpython.org is the following information:<br> <br> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;">The VPython installer installs the Visual 3D module, example programs, the Visual documentation, and VIDLE, an improved version of the IDLE program editor, into Lib/site-packages/visual in the Python folder. It also installs if necessary the numpy module, which Visual requires. A shortcut to VIDLE is placed on the desktop which references the VPython example programs.<br> <br> Bruce Sherwood<br> </span><br> Beracah Yankama wrote: <blockquote cite="mid:4BE...@mi..." type="cite"> <pre wrap="">Hi all, Having visited the site and the buglist, which appears to be old/not in use anymore, I figured that I would just email this list. I'm concerned about a possible memory leak, which I've traced down to be either the way vpython keeps numpy ndarray position objects around or numpy failing to deallocate them properly. I'm using windows, so I'm assuming that the vpython lib on windows is statically linked since the main page didn't tell me anything about downloading numpy. I create and destroy hundreds of thousands of objects in the vpython window lifetime, and I notice that the memory slowly grows until the application crashes after a day or so. I made a test script, that only creates objects in the window, then deletes them over and over, and I found the long-term memory use/growth to be related linearly to the .pos attribute. For instance, a curve with 20 points leads to unreleased memory that grows 10x as fast as curves with only 2 points. Similarly, if I assign the .pos attribute as a numpy ndarray directly, the leak grows twice as fast as if assign the individual xyz values. I've upgraded my numpy without any change. Also, in aug 2009, numpy users of v1.3.0 noticed a memory leak in the ndarray subclass: <a class="moz-txt-link-freetext" href="http://www.mail-archive.com/num...@sc.../msg19776.html">http://www.mail-archive.com/num...@sc.../msg19776.html</a> I included the test code here -- please let me know if I've just missed something totally obvious about the way the objects/positions should be deallocated. Thanks! Beracah //------------------------------------------------------ import visual.crayola import visual import random import thread import sys import time win=800 L = 16 # should correspond to the radius of the smallest tree width=1000 height=700 scene = visual.display(title="3D Relational Viz Engine", width=1000, height=700, range=2*L, forward=(0,-.2,-1)) scene.fullscreen = 0 scene.autocenter = 0 scene.autoscale = 0 scene.userzoom = 1 rootframe = visual.frame() globjects = [] # this is the test; loop infinitely creating objects # drestroy them every X times # pretty stuff. def rotateit(): global rootframe ir=0 while 1: if (ir % 120 ) == 0: x = 1 if (random.random() < .1) else 0 y = 1 if (random.random() < .1) else 0 z = 1 if (random.random() < .1) else 0 z = 1 if ((x + y + z) == 0) else z # print (x,y,z) # chang direction randomly direction = -1.0 if (random.random() < .1) else 1.0 speed = 4.0 if (random.random() < .1) else 1.0 if rootframe: rootframe.rotate(angle=(speed*direction*visual.pi/2160.), axis=(x,y,z), origin=(0,0,0)) # rootframe.rotate(angle=visual.pi/360., axis=(1,0,0), origin=(0,0,0)) ir+=1 #print ir # rotate by Z every hundred or so. if (ir % 5) == 0: rootframe.rotate(angle=(speed*direction*visual.pi/1080.), axis=(x,y,z), origin=(0,0,0)) visual.rate(90) rotatethread = thread.start_new_thread(rotateit, ()) totalobjects = 0 # for i in xrange(100): while 1: # print len(globjects), totalobjects if 0: # len(globjects) % 2 == 0: globjects.append( visual.label( pos=( random.uniform(-10,10), random.uniform(-10,10), random.uniform(-10,10)), # text=str(random.uniform(0,100000000)) + str(random.uniform(0,100000000)) + str(random.uniform(0,100000000)), # memory is DEF a f(string length) text = 'a', # now lets see if somehow the number of objects is not being freed... frame=rootframe, linecolor=(255,0,0), height=10, opacity=.125, border=0, box=0, color=(255,0,0)) ) else: globjects.append( visual.curve( pos=[ (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)), (random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)) ], color=(0,0,255), frame=rootframe)) # time.sleep(1.0) if len(globjects) >= 1000: totalobjects += len(globjects) print totalobjects for i in reversed(xrange(len(globjects))): globjects[i].visible = 0 # globjects[i].remove(0) for p in xrange(len(globjects[i].pos)): # print p, type(globjects[i].pos[p]) # print point "" del globjects[i] del globjects globjects = [] visual.rate(1000) ------------------------------------------------------------------------------ _______________________________________________ Visualpython-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Vis...@li...">Vis...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/visualpython-users">https://lists.sourceforge.net/lists/listinfo/visualpython-users</a> </pre> </blockquote> </body> </html> |