# Crash when closing game: Object from PIE level still referenced. Shortest path from root:    (Object is not currently rooted)

**URL:** <https://forums.unrealengine.com/t/crash-when-closing-game-object-from-pie-level-still-referenced-shortest-path-from-root-object-is-not-currently-rooted/311375>\
**Category:** Editor Scripting\
**Tags:** reference, pie, unreal-engine, question\
**Created:** [March 17, 2015, 12:25pm UTC](https://forums.unrealengine.com/t/crash-when-closing-game-object-from-pie-level-still-referenced-shortest-path-from-root-object-is-not-currently-rooted/311375 "2015-03-17T12:25:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pseudocorpus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pseudocorpus/32/453689_2.png) [@Pseudocorpus](https://forums.unrealengine.com/u/Pseudocorpus)\
**Post date:** [March 17, 2015, 12:25pm UTC](https://forums.unrealengine.com/t/crash-when-closing-game-object-from-pie-level-still-referenced-shortest-path-from-root-object-is-not-currently-rooted/311375/1 "2015-03-17T12:25:04Z")

</div>

It seems the following code causes the crash (located in PostInitializeComponents):

```
//Get and assign Material Instance
	if (Pickup_Material != NULL)
	{
		//Pickup_Material is a UMaterialInstanceDynamic, inherited from the parent class
		Pickup_Material->SetVectorParameterValue(FName(TEXT("Tint")), ColorTint);

		TArray<FSkeletalMaterial> CharMats;

		if (SkelMesh_Gear_Male != NULL)
		{
			CharMats = SkelMesh_Gear_Male->Materials;

			for (int32 iMats = 0; iMats < CharMats.Num(); iMats++)
			{
				if (SkelMesh_Gear_Male->Materials[iMats].MaterialInterface == Pickup_Material_Origin)
				{
					SkelMesh_Gear_Male->Materials[iMats].MaterialInterface = Pickup_Material;
				}
			}
		}

		if (SkelMesh_Gear_Female != NULL)
		{
			CharMats = SkelMesh_Gear_Female->Materials;

			for (int32 iMats = 0; iMats < CharMats.Num(); iMats++)
			{
				if (SkelMesh_Gear_Female->Materials[iMats].MaterialInterface == Pickup_Material_Origin)
				{
					SkelMesh_Gear_Female->Materials[iMats].MaterialInterface = Pickup_Material;
				}
			}
		}
	}

```

A possibility could be that the Material Instance “Pickup\_Material” (which is declared in the parent class of this actor) causes the crash, because I am re-using it on a skeletal mesh of the child class. I read that this causes a memory leak in the packaged project. How can I resolve this?

Thanks in advance
