[vtkusers] vtkDelete in java gc finalization
Bernard Giroux
giroux at geo.polymtl.ca
Thu Sep 28 09:33:11 EDT 2006
Le 06-09-27 à 09:32, TARRAGO Xavier 103783 a écrit :
> Hello,
> I use vtk from java bindings and I am very surprised about the
> way garbaging is handled. vtkDelete is called from finalize. But
> finalize is runned in a thread that is not the main thread (or
> eventThread for swing). So I expected some synchronization in the
> reference counting. But I cannot find any clue of that. Please let
> me know that I have missed something. If I did not, I expect some
> ref counting corruption to happend from java finalization.
>
> Best regards,
>
This might explain the crash I describe in a previous mail (see
below). I ended up copying the cell point values in a java array
instead of using the vtk object to avoid the crash.
--- previous mail here ---
I am sort of newbie at this and would like any advice... I am
developing on a dual G5 running Tiger.
I have a class with a private vtkPolyData member (facets), which I
initialize in a method the following way:
public void setFacets(vtkPolyData f) {
if (facets == null)
facets = new vtkPolyData();
facets.DeepCopy(f);
facets.Update();
...
}
I use it later on in another method:
public double gz(double[] po) {
if (facets == null) {
throw new NullPointerException();
}
double gz = 0.0;
vtkPoints vtkPts = new vtkPoints();
System.out.printf("Number of cells: %d\n", facets.GetNumberOfCells());
for (int i = 0; i < facets.GetNumberOfCells(); ++i) {
System.out.print(i + " " + facets.GetNumberOfCells());
int nEdges = facets.GetCell(i).GetNumberOfEdges();
System.out.print(" . 1a");
vtkPts.DeepCopy(facets.GetCell(i).GetPoints());
...
}
At some point in the above loop, the program crashes at the
GetNumberOfEdges() call, with the following message.
EXC_BAD_ACCESS (0x0001)
KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
Thread 12 Crashed:
0 Java_vtk_vtkTriangle_GetNumberOfEdges_15 + 68
*** This does not happen if I run the program on just one CPU ***
Any idea???
>
> Xavier Tarrago
> Service Système et Simulation pour la Surveillance et le Contrôle
> Non Destructif
> CEA Saclay
> 91191 Gif sur Yvette Cedex
> Tel :+ 33 (0)169 088 808
> Fax:+ 33 (0)169 087 597
> http://www-civa.cea.fr
> xavier.tarrago at cea.fr
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/
> Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
---
Bernard Giroux, ing., Ph.D.
Associé de recherche
http://geo.polymtl.ca/~giroux
More information about the vtkusers
mailing list