<div dir="ltr">Hi Seb,<div><br></div><div>first of all, thanks for your feedback.</div><div><br></div><div>I have taken a look at the C++ code of vtkImageReader: it seems to me that main allocation happens inside ExecuteDataWithInformation() method, which in turn calls vtkImageData::AllocateScalars(), which in turn calls vtkDataArray::CreateDataArray(), which finally I think ends up calling ::New() on the typed data array (probably, vtkUnsignedShortArray in my case).</div><div><br></div><div>If I were to write my own image reader, for instance, I am not sure how I could detect eventual out-of-memory errors, since they would actually happen inside other VTK classes. Maybe some try-catch blocks in my own image reader may help me?</div><div>Any suggestion would be greatly appreciated.</div><div><br></div><div>I am looking forward to hearing from you.</div><div>Thanks and best regards,</div><div><br></div><div>Marco Sambin</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 15, 2014 at 4:30 PM, Sebastien Jourdain <span dir="ltr"><<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Marco,<div><br></div><div>I don't have the answer but if there is no solution as today, maybe adding another method on the reader that could first validate that enough memory is available, might be an option. Specially in Java when such call make the JVM crash.</div><div><br></div><div>That change will need to happen on the C++ side. But at that point I'm not sure how to check that on the C++ side either. Maybe Berk, Dave or Brad might have some insight.</div><div><br></div><div>Thanks,</div><div><br></div><div>Seb</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 15, 2014 at 3:04 AM, Marco Sambin <span dir="ltr"><<a href="mailto:m.sambin@gmail.com" target="_blank">m.sambin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all.<div>In my VTK-based Java application, I am reading a "raw volume file" (containing a set of CT slices) through some Java code looking like this:</div><div><br></div><div><div>[...]</div><div>vtkImageReader imageReaderVTK =  new vtkImageReader();</div><div>imageReaderVTK.FileLowerLeftOn();</div><div>imageReaderVTK.SetFileDimensionality(3);</div><div>imageReaderVTK.SetFileName(curRawVolFile.getAbsolutePath());</div><div>imageReaderVTK.SetDataExtent(0, sliceCols - 1,</div><div>                      0, sliceRows - 1,</div><div>                      0, numOfUsedImages - 1);</div><div>imageReaderVTK.SetDataSpacing(xSpacing, ySpacing, zSpacing);</div><div>imageReaderVTK.SetDataOrigin(0.0, 0.0, 0.0);</div><div>imageReaderVTK.SetDataScalarTypeToUnsignedShort();</div><div>imageReaderVTK.SetDataByteOrderToBigEndian();</div><div><br></div><div>// The following call may cause a process crash due to out-of-memory</div><div>imageReaderVTK.UpdateWholeExtent();</div><div>[...]</div></div><div><br></div><div>I am then passing this volume to a vtkImagePlaneWidget for some reslicing.</div><div><br></div><div>As the last comment (in the code fragment above) suggests, in some cases I get a crash of the JVM process, due to the fact the reader goes out of memory while actually reading and allocating the whole volume in memory. This especially happens when using a 32-bit JRE.</div><div>I understand that I cannot read a huge volume in memory if just a small amount of memory is available to the process, but my question is:</div><div>is there a way to manage "more gracefully" this out-of-memory from Java code, in such a way to be able to inform the user that "Not enough memory is available to read this volume", instead of causing a JVM crash?</div><div><br></div><div>I am using VTK 6.1.0.</div><div><br></div><div>Thanks for any hint/suggestion about this topic.</div><div><br></div><div>Best regards,</div><div><br></div><div>Marco</div><div><br></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>