Re: [PyOpenGL-Users] memory trouble with a very simple program
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-04-07 17:15:09
|
I'm unable to provoke the symptoms you describe on Win2K with wxPython 2.4.0 and PyOpenGL 2.0.1.03. Note that there quite a few memory leaks patched in the 2.0.1.xx series (which is still in alpha testing). If you're using 2.0.1, please give more details regarding your system (e.g. Python version, PyOpenGL version, wxPython version). I only have Win2K for testing, but the code is the same, so if the leak's on our side it's likely going to show up in 2K as well as XP. Enjoy, Mike Champ Hippy wrote: >Hi, > >When I run the following program (see below), the memory that is used >by my system (windows XP) as indicated by the task manager is >constantly increasing when I hide and show this PyOpenGL application >with another window (like the task manager for instance). Of course, >the memory increase is not huge (4 Ko at a time in general) but it >does not seem to reach an upper limit. Furthermore, I have the same >problem for another (more complex) application where I refresh the >window with new drawings : in this case the memory trouble gets really >problematic. > >What am I doing wrong? > >Thanks for your reply. > >Bernard > >#---------------------------------------------------------------------- >from wxPython.wx import * >from wxPython.glcanvas import * >from OpenGL.GL import * >from OpenGL.GLUT import * > >class MyCanvasBase(wxGLCanvas): > def __init__(self, parent): > wxGLCanvas.__init__(self, parent, -1) > self.init = False > EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) > EVT_SIZE(self, self.OnSize) > EVT_PAINT(self, self.OnPaint) > > def OnEraseBackground(self, event): > pass # Do nothing, to avoid flashing on MSW. > > def OnSize(self, event): > size = self.GetClientSize() > if self.GetContext(): > self.SetCurrent() > glViewport(0, 0, size.width, size.height) > > def OnPaint(self, event): > dc = wxPaintDC(self) > self.SetCurrent() > if not self.init: > self.InitGL() > self.init = True > self.OnDraw() > >class RectangleCanvas(MyCanvasBase): > def InitGL(self): > glMatrixMode(GL_PROJECTION); > glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0); > glMatrixMode(GL_MODELVIEW); > glTranslatef(0.0, 0.0, -2.0); > > def OnDraw(self): > glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > glColor3f(0.0,0.0,1.0) > glRectf(-0.5,-0.5,0.5,0.5) > > self.SwapBuffers() > >#---------------------------------------------------------------------- > >def _test(): > class MyApp(wxApp): > def OnInit(self): > frame = wxFrame(None, -1, "Test", wxDefaultPosition, >wxSize(600,300)) > win = RectangleCanvas(frame) > frame.Show(True) > ##self.SetTopWindow(frame) > return True > > app = MyApp(0) > app.MainLoop() > >if __name__ == '__main__': > _test() > > > >------------------------------------------------------- >This SF.net email is sponsored by: ValueWeb: >Dedicated Hosting for just $79/mo with 500 GB of bandwidth! >No other company gives more support or power for your dedicated server >http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ >_______________________________________________ >PyOpenGL Homepage >http://pyopengl.sourceforge.net >_______________________________________________ >PyOpenGL-Users mailing list >PyO...@li... >https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > -- _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |