# Java Wrapper memory management

**URL:** https://discourse.vtk.org/t/java-wrapper-memory-management/16312
**Category:** Support
**Tags:** code
**Created:** [March 4, 2026, 8:44am UTC](https://discourse.vtk.org/t/java-wrapper-memory-management/16312 "2026-03-04T08:44:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Haddy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/haddy/32/10546_2.png) [@Haddy](https://discourse.vtk.org/u/Haddy)
#### Post date: [March 4, 2026, 8:44am UTC](https://discourse.vtk.org/t/java-wrapper-memory-management/16312/1 "2026-03-04T08:44:01Z")

</div>

I have a question about using vtk inside Java.

Is it neccessary to call Delete() on something like a vtkImageData object, or is the memory safely released when it falls out of Scope or is set to null?

---

<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: [March 4, 2026, 3:53pm UTC](https://discourse.vtk.org/t/java-wrapper-memory-management/16312/2 "2026-03-04T15:53:41Z")

</div>

I would expect it is automatic and `Delete()` is only necessary if you call `Register()` yourself.

@dgobbi @vbolea

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [March 5, 2026, 3:06am UTC](https://discourse.vtk.org/t/java-wrapper-memory-management/16312/3 "2026-03-05T03:06:11Z")

</div>

I haven’t looked at this code for a long time but I’m pretty sure it’s safe to call Delete() if you want to dispose of the underlying C++ object before the Java wrapper object goes out of scope. Otherwise let the garbage collector handle it.
