Hi Serge,<br><br>I think I encountered the same problem with Java a few days ago. I posted a question on this forum but received no answer.<br>What I did, is that I added an object in a static java field of vtkObject and I 'synchronize' the 'Delete' and all my calls to VTK API on that object, in order to avoid to concurrent calls to VTK API. However, this solution is not very nice and I am not sure it will solve the problem.<br>
<br>I would be really very interested in any other solution to this problem.<br><br>Laurent<br><br><div class="gmail_quote">On Thu, Oct 23, 2008 at 5:29 PM, Serge Lalonde <span dir="ltr"><<a href="mailto:serge@infolytica.com">serge@infolytica.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
Hi David,<br>
<br>
I tried calling Dispose on the objects, but that doesn't work for many
reasons.<br>
<ol>
<li>It's ugly.</li>
<li>It's very difficult to maintain.</li>
<li>Often, wrapper objects are not stored in a variable if the call
to Get*() is daisy-chained, so it's impossible to call Dispose() on it.<br>
ex: actor.GetMapper().SetLookupTable(lut).<br>
Here the mapper wrapper holds a reference to the VTK mapper until the
GC decides to cleanup.</li>
</ol>
So in practice, explicitly calling Dispose() is not really possible.<br>
<br>
It seems to me to be a fairly simple problem to solve that would
benefit all VTK wrappers and also C++. I've come up with a scheme to
fix it, but I didn't want to implement it if there was an official VTK
workaround. If nobody else replies , I'll implement it and post my code
for this in case others they find it useful.<br>
<br>
BTW, do you happen to know what
vtkGarbageCollector::DeferredCollectionPush() is supposed to do? It
looks to me like it could be part of the solution, but as it is, it
doesn't seem to fix anything (I used it and traced the code).<br>
<br>
Thanks.<br>
<br>
David Cole wrote:
<blockquote type="cite"><div class="Ih2E3d">To avoid the problem, try calling Dispose on any .NET
objects associated with a RenderWindow from the main GUI thread
*before* those .NET objects are out of scope and eligible for garbage
collection.<br>
<br>
<div>You can also get that error even solely on the main GUI thread
if objects associated with the RenderWindow are not Disposed *before*
the render window itself goes out of scope.</div>
<div><br>
</div>
</div><div><br>
<div class="gmail_quote"><div class="Ih2E3d">On Wed, Oct 22, 2008 at 4:44 PM, Serge
Lalonde <span dir="ltr"><<a href="mailto:serge@infolytica.com" target="_blank">serge@infolytica.com</a>></span>
wrote:<br>
</div><div class="Ih2E3d"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I have run into a problem caused by a conflict between the .NET garbage
collection and the VTK garbage collection. However, I believe that this
is a general problem that could occur when using Java or even C++ if a
vtk object were deleted in a different thread.<br>
<br>
Because certain objects require that they be freed in the main thread
(actually the rendering thread) because they need to free OpenGL
resources in their ReleaseGraphicResources() method (ex:
vtkOpenGLTexture), they cannot be freed in the .NET garbage collection
thread. Doing so causes an error in
vtkWin32OpenGLRenderWindow::MakeCurrent() at line 218 when calling
wglMakeCurrent() because the rendering context is not valid for this
thread.<br>
<br>
I did some digging and found
vtkGarbageCollector::DeferredCollectionPush() that looked perfect.
However, it unfortunately didn't work. There doesn't seem to be much
documentation on this or in the mailing list.<br>
<br>
1. Does anyone know what DeferredCollectionPush() does and what it is
meant to actually fix?<br>
2. Has anyone run into this problem and if so, how did you fix it?<br>
</blockquote>
</div></div>
</div>
</blockquote>
<div>-- <br>
<a href="http:://www.infolytica.com" target="_blank">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
(514) 849-8752 x236, Fax: (514) 849-4239
</div>
</div>
<br>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>