# TreeView & lifetime TreeViewItem

**URL:** <https://forum.juce.com/t/treeview-lifetime-treeviewitem/40036>\
**Category:** General JUCE discussion\
**Created:** [June 10, 2020, 6:12pm UTC](https://forum.juce.com/t/treeview-lifetime-treeviewitem/40036 "2020-06-10T18:12:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alatar](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@alatar](https://forum.juce.com/u/alatar)\
**Post date:** [June 10, 2020, 6:12pm UTC](https://forum.juce.com/t/treeview-lifetime-treeviewitem/40036/1 "2020-06-10T18:12:14Z")

</div>

Hi guys & JUCE team,

I am using a TreeView object, to display a large ValueTree with lots of items.  
As you know, inside each TreeView, there are lots of TreeViewItems.  
I have a question about the containing TreeViewItems.

What is the lifetime of the TreeViewItems? I mean, when do they get deleted?  
First I thought, they would get deleted, when they are no longer visible (when they are scrolled out of view). But that is not the case.  
I am asking, because I want to make sure, that the TreeView does not accidentally delete one of my TreeViewItems, while I am still running code inside of it. (Cause that could cause a crash).
