Application of Linked Lists for Managing Fragmented Memory in the Unity Game Engine: Approaches and Optimizations
Keywords:
Unity, linked list, memory fragmentation, garbage collector, object pooling, NativeContainer, Burst, performance optimizationAbstract
This paper examines the problem of managing fragmented managed memory in the Unity game engine. It proposes using linked lists combined with an object pool to minimize garbage?collector pauses and smooth out frame time. The relevance of this work stems from the fact that traditional contiguous?memory containers (arrays, List<T>) under frequent Instantiate/Destroy cycles cause heap fragmentation and abrupt stop?the?world GC passes, leading to noticeable FPS drops even with relatively small allocation volumes. The objective of the study is to systematically evaluate the effectiveness of various linked?list–based pool implementations (the standard LinkedPool<T>, intrusive lists, structural nodes in a NativeContainer) according to the metrics of GC?Alloc, frame time, and heap fragmentation in typical game scenarios involving the spawn of hundreds of prefabs per frame. The novelty lies in a comprehensive comparative analysis of four approaches within a unified Unity testbed, employing detailed profiling (Unity Profiler, Memory Profiler, ProfilerRecorder), and in demonstrating that even the simple use of LinkedPool<T> reduces the number of GC?stops by more than an order of magnitude, while advanced techniques (intrusive lists, NativeList within Burst/Jobs, pool sharding) additionally eliminate hidden allocations and render frame time practically stable. The key findings show that a linked list with object pooling enables O(1) Get/Release operations without massive copying and without requiring a contiguous memory block; the intrusive approach reduces node overhead; and “structural” nodes in a NativeContainer achieve zero GC allocations within Burst and Jobs subsystems. Pool sharding by object characteristics maintains constant complexity under scaling, and validation via profilers confirms zero GC?Alloc per frame and a stable memory?usage curve, making the proposed optimizations practically applicable to mobile and desktop Unity projects. This paper will interest game?engine developers, technical artists, and performance?optimization engineers working on Unity projects.
References
“LinkedPool,” Unity Documentation. https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Pool.LinkedPool_1.html (accessed Apr. 15, 2025).
“Understanding the managed heap,” Unity Documentation. https://docs.unity3d.com/560/Documentation/Manual/BestPracticeUnderstandingPerformanceInUnity4-1.html (accessed Apr. 16, 2025).
“Understanding Automatic Memory Management,” Unity Documentation. https://docs.unity3d.com/2019.3/Documentation/Manual/UnderstandingAutomaticMemoryManagement.html (accessed Apr. 17, 2025).
C. Gaudino, “Avoiding garbage collector performance spikes in Unity,” Embrace, Apr. 20, 2023. https://embrace.io/blog/garbage-collector-spikes-unity/ (accessed Apr. 18, 2025).
“LinkedList Class,” Microsoft. https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1?view=net-9.0 (accessed Apr. 19, 2025).
“Why Arrays have better cache locality than Linked list?,” Geeks for Geeks, Aug. 28, 2023. https://www.geeksforgeeks.org/why-arrays-have-better-cache-locality-than-linked-list/ (accessed Apr. 19, 2025).
“List.Add(T) Method,” Microsoft. https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.add?view=net-9.0 (accessed Apr. 20, 2025).
“Managed memory,” Unity Documentation. https://docs.unity3d.com/2021.2/Documentation/Manual/performance-managed-memory.html (accessed Apr. 21, 2025).
R. Torres Bonet, “Object Pooling in Unity 2021+,” The Game Dev Guru, Mar. 30, 2021. https://thegamedev.guru/unity-cpu-performance/object-pooling/ (accessed Apr. 21, 2025).
“Use object pooling to boost performance of C# scripts in Unity,” Unity Learn. https://learn.unity.com/tutorial/use-object-pooling-to-boost-performance-of-c-scripts-in-unity?uv=6&projectId=67bc8deaedbc2a23a7389cab#67a0d722edbc2a14cfcb73fc (accessed Apr. 22, 2025).
“Burst User Guide,” Unity. https://docs.unity3d.com/Packages/com.unity.collections%401.3/api/Unity.Collections.NativeList-1.html (accessed Apr. 25, 2025).
“Entity Changelog,” Unity. https://docs.unity3d.com/Packages/com.unity.entities%401.4/changelog/CHANGELOG.html (accessed Apr. 26, 2025).
“Memory Profiler module,” Unity Documentation. https://docs.unity3d.com/2020.2/Documentation/Manual/ProfilerMemory.html (accessed May 01, 2025).
“How to use Unity’s memory profiling tools,” Unity. https://unity.com/how-to/use-memory-profiling-unity (accessed May 03, 2025).
Downloads
Published
Issue
Section
License
Copyright (c) 2025 Yurii Sulyma

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Authors who submit papers with this journal agree to the following terms.