# Cannot Queue Expression Cache - Garbage Collection

**URL:** <https://forums.unrealengine.com/t/cannot-queue-expression-cache-garbage-collection/144144>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 21, 2020, 12:41pm UTC](https://forums.unrealengine.com/t/cannot-queue-expression-cache-garbage-collection/144144 "2020-05-21T12:41:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Kevz32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kevz32](https://forums.unrealengine.com/u/Kevz32)\
**Post date:** [May 21, 2020, 12:41pm UTC](https://forums.unrealengine.com/t/cannot-queue-expression-cache-garbage-collection/144144/1 "2020-05-21T12:41:55Z")

</div>

Hey Guys, I have a problem where my game crash when I call the SetImage() function from SImage.h as seen at line 11 below in the code snippet. The error is specifically. “Cannot queue the expression cache when it is about to be deleted.” MaterialShared.cpp [Line 2410} I believe this is pending GC? can anyone enlighten me?

My Slate widget inherits from SCompoundWidget, the error only ocurs when I call setimage()

Thank you

header.h

```auto

TSharedPtr<class SImage> PawnViewImage;

```

Source.cpp

```auto

1. UMaterialInterface* PawnViewMatInst = LoadObject<UMaterialInterface>(NULL, TEXT("MaterialInstanceConstant'/Game/Blueprints/UserWidgets/Minimap/Material/EnemyViewMat_Inst.EnemyViewMat_Inst'"));
2.
3. UMaterialInstanceDynamic* PawnViewMatDynamic = UMaterialInstanceDynamic::Create(EnemyViewMatInst, nullptr);
4.
5. FSlateBrush* PawnViewBrush = new FSlateBrush();
6.
7. PawnViewBrush->ImageSize = FVector2D(210.f, 210.f);
8. PawnViewBrush->DrawAs = ESlateBrushDrawType::Image;
9.
10.PawnViewBrush->SetResourceObject(EnemyViewMatDynamic);
11.PawnViewImage->SetImage(EnemyViewBrush);
12.PawnViewImage->SetColorAndOpacity(FLinearColor(0.3f, 1.f, 0.32f, 0.4f));

```

ChildSlot

```auto

+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SAssignNew(PawnViewImage, SImage)
]

```

MaterialShared.cpp snippet

```auto

void FMaterialRenderProxy::InvalidateUniformExpressionCache(bool bRecreateUniformBuffer)
{
check(IsInRenderingThread());

[Line 2410]
if (HasVirtualTextureCallbacks)
{
GetRendererModule().RemoveAllVirtualTextureProducerDestroyedCallbacks(this);
HasVirtualTextureCallbacks = false;
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/cannot-queue-expression-cache-garbage-collection/144144)._
