# application based on vtk will crash when memory is insufficient

**URL:** https://discourse.vtk.org/t/application-based-on-vtk-will-crash-when-memory-is-insufficient/7635
**Category:** Support
**Created:** [January 13, 2022, 9:33am UTC](https://discourse.vtk.org/t/application-based-on-vtk-will-crash-when-memory-is-insufficient/7635 "2022-01-13T09:33:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xianger.qi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xianger.qi](https://discourse.vtk.org/u/xianger.qi)
#### Post date: [January 13, 2022, 9:33am UTC](https://discourse.vtk.org/t/application-based-on-vtk-will-crash-when-memory-is-insufficient/7635/1 "2022-01-13T09:33:32Z")

</div>

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:

 ![Screenshot from 2022-01-13 17-30-48](https://discourse.vtk.org/uploads/default/original/2X/3/3901ec6a73ee43685a07a6251a53d7660b0c8437.png)

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

Thanks for your reading!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [January 22, 2022, 4:12pm UTC](https://discourse.vtk.org/t/application-based-on-vtk-will-crash-when-memory-is-insufficient/7635/2 "2022-01-22T16:12:30Z")

</div>

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.
