[vtkusers] vtkPoints, vtkIdsList, JNI memory errors and Jeff Lee!
Jeff Lee
jeff at cdnorthamerica.com
Mon Mar 27 06:49:02 EST 2006
Hi Eugene,
Try posting your code, or a piece of it which demonstrates the issue and
allows me to reproduce the problem and I'd be glad to have a look. I'm
sure there is some explanation/workaround for the problems you are having.
(See interspersed comments below...)
Regards,
Jeff
Eugene Kim wrote:
> Hi again,
>
> This is about the third time i've posted about this issue in the
> past couple weeks. I'm going to make this as clear as I possible can.
>
> 1) vtkPoints and vtkIdList are still broken.
>
> As far as I can tell, accessing these objects is not reliable in
> Java. When testing my application with small meshes, I rarely
> encountered errors. When I moved to testing with large meshes ( on
> the order of 300000 polygons ), these structures consistently failed
> in Java resulting in a segfault and a stacktrace report that always
> pointed to a method in vtkPoints or vtkIdList. After some inspection,
> it became clear that all I had to do was churn a large amount of print
> statements in between calls to these functions to break them. It
> seemed at this point that the more I flipped Java memory, the more the
> JNI code would break.
>
> The only thing that has gotten me anywhere at this point was to
> turn on incremental garabe collection in the JavaVM. Others have
> suggested that I use other VM's, like IBM's, which might have better
> memory mangement.
This is not a problem with memory management. It is probably an abuse
of the jni layer (which is arguably not your fault). Things like
accessing polydata's cell array is almost guaranteed to fail when
derefrenced in a tight loop. To workaround, you should cache the
cellArray object outside the loop to avoid repeated retrieval of the
pointer from the jni hashtable. This is just an example, when you post
your code, we can go through specific abuses.
>
> 2) I found a thread on this that is 4 years old
>
> An old thread with exchanges b/t a vtk user and Jeff Lee outlined
> a fix to this ( or related problem ). Now, I haven't actually tried
> this out yet, and I'm no expert on JNI, but upon inspection of this
> code in my own build and the suggested fix, they are indeed
> different. Perhaps the newer code is the right code after all, but as
> far as I can tell it STILL DOES NOT WORK. This thread is 4 years old,
> and I wonder if anyone could confirm any kind of fix. ( Or even have
> a developer acknoweldge the problem ). Because the problem also
> exists independently in vtkIdList for me, this problem does seem to be
> shared due to some oversight in the java wrapping code as Jeff Lee has
> stated. Please someone, tell me i'm not crazy, ( or more bearably
> just stupid ).
No fix that I'm aware of, I'm not sure which exchange you are talking
about though (there have been many).
>
> 3) I shouldn't even have to worry about vtkPoints
>
> I'm going to use this as an opportunity to point out an even
> larger problem. The only reason i'm even dealing with the vtkPoints
> data object is that vtkPolyData is not working properly, ( or again
> i'm just stupid ). If I load in a .vtk file into a vtkPolyData
> object, all of your convenient methods which hold the vertices, lines,
> triangles, etc... do not work. I cannot even query the number of
> vertices in the object, and the vtkCellArray which holds these objects
> does not exist. These methods preumably exist to make my life easy, (
> i have tried BuildCells and all that, could I be missing something? ),
> but I am forced to bypass them and gather every cell in my object, and
> then every point from every cell, and eliminate common points based on
> the point ids i recieve. It's ugly, it's tedious, there are memory
> errors dealing with this, and I should not need to deal with it.
right, there is some other problem - did you try reader->Update() before
accessing the polydata?
>
> These past couple weeks i've been trying to convcine myself that I am
> not crazy and that these problems really do exist. I wonder why it
> isn't a bigger issue, as these are very core objects in VTK. Ideally,
> I would like someone to slap me in the face and show me what i
> should've been doing this entire time, but no one seems to want to
> answer =(.
Again, post some code and we can get to the bottom of it.
>
> Thanks for your patience,
> Eugene Kim
> _______________________________________________
> 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
>
>
More information about the vtkusers
mailing list