From: Combe, C. <C....@na...> - 2002-06-03 12:02:07
|
thanks max - but unfortunately i still have the same problem. I should = have said before that the destroy method in the classes that inherit from GLAnimCanvas call cvsDispose, sorry for this ommission. I changed the = code so that cvsDispose is called before I remove the canvas from the = JPanel, but it didn't help. I've also tried destroying the GLContext myself rather = than via cvsDispose but no luck there. The action performed method for the = change view button is now as follows (i think my desperation is apparent in = the way the switch statement has been written :-)=20 void changeView_actionPerformed(ActionEvent e) { land.running =3D false; while (land.isAlive()) { System.out.println("waiting"); try {Thread.sleep(150);} catch (InterruptedException ex) {System.err.println(ex.toString());} } land =3D null; switch (canvasType) { case 1: displayPanel.remove((Canvas2D) canvas); canvasType =3D 2; canvas =3D new Shaded3D (800, 600); displayPanel.add((Shaded3D) canvas); break; case 2: ((Shaded3D)canvas).stop(); ((Shaded3D)canvas).getGLContext().gljFree(); ((Shaded3D)canvas).getGLContext().gljDestroy(); ((Shaded3D) canvas).cvsDispose(); ((Shaded3D)canvas).setVisible(false); ((Shaded3D)canvas).setEnabled(false); displayPanel.remove((Shaded3D) canvas); canvas =3D null; canvasType =3D 3; canvas =3D new Coloured3D (800, 600); displayPanel.add((Coloured3D) canvas); break; case 3: ((Coloured3D) canvas).stop(); ((Coloured3D)canvas).getGLContext().gljFree(); ((Coloured3D)canvas).getGLContext().gljDestroy(); ((Coloured3D) canvas).cvsDispose(); ((Coloured3D)canvas).setVisible(false); ((Coloured3D)canvas).setEnabled(false); displayPanel.remove((Coloured3D) canvas); canvas =3D null; canvasType =3D 1; canvas =3D new Canvas2D (); displayPanel.add((Canvas2D) canvas); break; } land =3D new NormLand(canvas); canvas.setLand(land); land.running =3D true; land.start(); } 'land' is the thread that the model runs in, i know its not the this = thread that i'm not recovering resources from as the button that stops and = restarts the model works fine. Also, after chnaging the view a few times, the = program still runs at the normal speed when seen in the 2D display, its only = the GLCanvas's that are slowed down. I'm using java version 1.3.1_02.=20 cheers, colin -----Original Message----- From: Max Gilead [mailto:gi...@li...] Sent: 02 June 2002 19:31 To: gl4...@li... Subject: Re: [gl4java-usergroup] how to make GLAnimCanvas release all resources? Combe, Colin wrote: >any suggestions about what i'm doing wrong? > =20 > Most probably it's missing cvsDispose call (from GLCanvas Javadoc): "IF you remove/release a GLCanvas, e.g. you want to close/dispose = it=B4s=20 Window (which contains this GLCanvas), you HAVE TO call: cvsDispose <cid:par...@li...> =20 You should call this before releasing/dispose this Window ! Also you = can=20 overwrite this class, to dispose your own elements, e.g. a Frame etc. - = but be shure that you call cvsDispose implementation call this one !" HTH, Max |