application based on vtk will crash when memory is insufficient

when i allocate the space of memory which is more than the capacity of computer ram in vtk, and the application will crash with no exception thrown. just like the code below:

how could i prevent the situation to happen? Is there exist any method like try/catch?

Thanks for your reading!

Not all allocation routines are C++ new. Internal libraries use malloc all the time and very few guard against failed allocations. Since these return NULL, it will end up in a crash.