<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.5296.0" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>My java application crashes when the GC finalizes a 
rendering window.<BR>The problem can be reproduced with the Java examples of 
<BR><A 
href="http://ij-plugins.sourceforge.net/vtk-examples/index.html">http://ij-plugins.sourceforge.net/vtk-examples/index.html</A></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The examples must be modified in order to remove 
all references to the rendering window and its component.</FONT></DIV>
<DIV><SPAN class=834504612-19052006></SPAN><FONT face=Arial size=2>O<SPAN 
class=834504612-19052006>hterwise the GC would not free them. </SPAN>I modified 
vtkCanvas and added the following lines:<BR></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT face="Courier New">&nbsp;&nbsp;&nbsp; public 
void removeNotify() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
super.removeNotify();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ren=null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cam = 
null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lgt = 
null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
rw=null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
iren=null;<BR>&nbsp;&nbsp;&nbsp; }<BR></FONT>&nbsp;<BR>I added a 
System.out.println in the finalize of the vtkObjectBase, to be able to trace 
easily the finalized objects.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>When the GC finalizes the 
vtkGenericRenderWindowInteractor or the vtkRenderWindow,<BR>the java program 
exits with the following error:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2><FONT 
face="Courier New">Finalize:vtk.vtkRenderWindow<BR>Finalize:vtk.vtkGenericRenderWindowInteractor<BR>#<BR># 
An unexpected error has been detected by HotSpot Virtual 
Machine:<BR>#<BR>#&nbsp; EXCEPTION_ACCESS_VIOLATION (0xc0000005) at 
pc=0x00000000, pid=4844, tid=4488<BR>#<BR># Java VM: Java HotSpot(TM) Client VM 
(1.4.2_11-b06 mixed mode)<BR># Problematic frame:<BR># C&nbsp; 
0x00000000<BR>#<BR># An error report file with more information is saved as 
hs_err_pid4844.log<BR>#<BR># If you would like to submit a bug report, please 
visit:<BR>#&nbsp;&nbsp; </FONT><A 
href="http://java.sun.com/webapps/bugreport/crash.jsp"><FONT 
face="Courier New">http://java.sun.com/webapps/bugreport/crash.jsp</FONT></A><BR><FONT 
face="Courier New">#</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>In the vtk logs, the following error is 
reported:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>ERROR: In 
\working\tools\Vtk5.0\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 
238<BR>vtkWin32OpenGLRenderWindow (08E6C540): wglMakeCurrent failed in 
MakeCurrent(), error: The handle is invalid.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>When I trace the C Code, I find that the program 
exits in the call to glDisable((GLenum)cur_light),<BR>in the following 
function:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>void 
vtkWin32OpenGLRenderWindow::Clean()<BR>{<BR>&nbsp; vtkRenderer *ren;<BR>&nbsp; 
GLuint id;<BR>&nbsp; <BR>&nbsp; /* finish OpenGL rendering */<BR>&nbsp; if 
(this-&gt;ContextId) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; 
this-&gt;MakeCurrent();</FONT></DIV>
<DIV><FONT face="Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&nbsp;&nbsp; /* first delete all the 
old lights */<BR>&nbsp;&nbsp;&nbsp; for (short cur_light = GL_LIGHT0; cur_light 
&lt; GL_LIGHT0+VTK_MAX_LIGHTS; cur_light++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
glDisable((GLenum)cur_light);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp; <BR>...</FONT></DIV>
<DIV><FONT face="Courier New"></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><SPAN class=834504612-19052006>I tried to remove 
all props from the rendering window before its finalisation, but it does not 
help.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Can anybody help me? With a patch, a workaround or 
some advice.</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks in adavance!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Laurent <BR></FONT></DIV></BODY></HTML>