# Garbage Collector Guarantees

**URL:** <https://forums.unrealengine.com/t/garbage-collector-guarantees/320549>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 2, 2015, 11:15pm UTC](https://forums.unrealengine.com/t/garbage-collector-guarantees/320549 "2015-06-02T23:15:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_80d7367e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_80d7367e1](https://forums.unrealengine.com/u/anonymous_user_80d7367e1)\
**Post date:** [June 2, 2015, 11:15pm UTC](https://forums.unrealengine.com/t/garbage-collector-guarantees/320549/1 "2015-06-02T23:15:50Z")

</div>

Are there guarantees for the garbage collector?

Like, that an object doesn’t get destroyed by the garbage collector in the same frame, as it was created?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [June 9, 2015, 6:15pm UTC](https://forums.unrealengine.com/t/garbage-collector-guarantees/320549/2 "2015-06-09T18:15:20Z")

</div>

Hello,

To ensure that the object will be properly handled in terms of Garbage Collection (in other words, it won’t get deleted while still being referenced in your code), please make sure that the following conditions are met:

1. You use UObject and UObject-derived objects (in other case, please use Smart Pointers);

2. Your class members are declared as UPROPERTY;

Please also note that the only type-safe container is TArray.

If you like to learn more about Garbage Collection in Unreal Engine 4, please go here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

Hope this helped!

Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_80d7367e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_80d7367e1](https://forums.unrealengine.com/u/anonymous_user_80d7367e1)\
**Post date:** [August 8, 2015, 7:46pm UTC](https://forums.unrealengine.com/t/garbage-collector-guarantees/320549/3 "2015-08-08T19:46:14Z")

</div>

Can I assume, that the object won’t be deleted by the GC during the same frame as it was created? Event if it’s not referenced by a UProperty?
