# How to amortize the performance cost of garbage collection and level streaming?

**URL:** <https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490>\
**Category:** World Creation\
**Tags:** Level-Streaming, garbage-collection, unreal-engine, question\
**Created:** [August 31, 2015, 3:41pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490 "2015-08-31T15:41:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KGist](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KGist](https://forums.unrealengine.com/u/KGist)\
**Post date:** [August 31, 2015, 3:41pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/1 "2015-08-31T15:41:28Z")

</div>

**Are there any recommended methods for amortizing the costs of garbage collection and visibility changes? Can we control the number of actors per frame that are destroyed or have visibility changes applied?**

_Details:_

We are seeing major performance spikes related to level streaming. We are currently using LevelStreamingVolumes but would expect to see similar results using WorldComposition.

The largest spike occurs when the garbage collector cleans up an unloaded level. This spike persists over several frames. Additionally, we see single frame spikes when a level’s visibility changes (as all actors in the the level change visibility in a single frame).

 ![56477-asyncloadandvisibility.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/7/d87fa400eb49384f9855d65676a3d87beb9f6e92.png)

![56478-visibilityoffthenunload.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/0/f30ac2c2d5805cd9dd251e7b30ddaa7fe93d3f5e.png)

The above image shows the performance hit of asynchronously loading the level, followed by the level becoming visible.

The second image shows the previous level losing visibility (via LevelStreamingVolume), followed by the prolonged spike of garbage collecting the unloaded level.

---

<div class="post-metadata">

**Author:** ![Philippe23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philippe23](https://forums.unrealengine.com/u/Philippe23)\
**Post date:** [November 30, 2015, 7:23pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/2 "2015-11-30T19:23:19Z")

</div>

I’m seeing similar issues with unloading streaming levels; did you make an progress on this?

---

<div class="post-metadata">

**Author:** ![KGist](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KGist](https://forums.unrealengine.com/u/KGist)\
**Post date:** [November 30, 2015, 9:08pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/3 "2015-11-30T21:08:11Z")

</div>

Hi Philippe,

Unfortunately, this remains an open, but low-priority, issue for us. We have not found a way to change the Garbage Collector’s behavior with respect to the number of objects cleaned per frame or the total time spent in GC per frame.

However, the Trello roadmap lists “Garbage Collection performance optimizations” as underway for November, so we’re hoping to see some marked improvement in 4.11 or 4.12.

---

<div class="post-metadata">

**Author:** ![Philippe23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philippe23](https://forums.unrealengine.com/u/Philippe23)\
**Post date:** [November 30, 2015, 9:13pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/4 "2015-11-30T21:13:22Z")

</div>

Thanks for the update!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d35eb822](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d35eb822](https://forums.unrealengine.com/u/anonymous_user_d35eb822)\
**Post date:** [May 8, 2018, 11:52am UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/5 "2018-05-08T11:52:52Z")

</div>

Three years later and we still see the same heavy spikes on level load and unload. Was there ever anything done on the GC regarding these issues? If so, is there some documentation or at least code you can refer to, so we can learn how to mitigate the issues?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bde6bc53](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bde6bc53](https://forums.unrealengine.com/u/anonymous_user_bde6bc53)\
**Post date:** [October 1, 2019, 4:46pm UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/6 "2019-10-01T16:46:12Z")

</div>

another year and the same problem …

---

<div class="post-metadata">

**Author:** ![stdrag](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@stdrag](https://forums.unrealengine.com/u/stdrag)\
**Post date:** [June 23, 2021, 11:17am UTC](https://forums.unrealengine.com/t/how-to-amortize-the-performance-cost-of-garbage-collection-and-level-streaming/330490/7 "2021-06-23T11:17:48Z")

</div>

I still have same issue.
