[vtk-developers] How to catch OutOfMemory errors using VTK with Java

Mathieu Malaterre mathieu.malaterre at gmail.com
Mon Jun 22 14:20:55 EDT 2009


On Mon, Jun 22, 2009 at 4:46 PM, Timothy M. Shead<tshead at sandia.gov> wrote:
> Jeff Baumes wrote:
>>
>> Someone else may be able to answer better, but even if you wrote your
>> application in C++, I don't think that VTK throws exceptions for things like
>> out of memory errors.
>
> operator new throws a C++ exception for out-of-memory conditions, so any
> code that invokes it (directly or indirectly) may cause an exception.
> Converting those C++ exceptions into Java exceptions would require
> modifications to the wrapper-generator, to put a try-catch block around
> every method that calls into C++.  Boost.Python does this, for example.

The reason #1 you would reach a out-of-memory condition is within the
vtkDataArray allocation. In VTK you should have a look at:

template <class T>
int vtkDataArrayTemplate<T>::Allocate(vtkIdType sz, vtkIdType)


it calls vtkErrorMacro which you can observe using vtkCommand::ErrorEvent

HTH
-- 
Mathieu



More information about the vtk-developers mailing list