Why Is Memory Usage Still High After Optimizing Unity Resources?
Even after optimizing textures, meshes, animations, and audio assets, many Unity projects still experience unexpectedly high memory usage. The remaining memory often comes from runtime systems such as Lua, Mono object references, Native Heap allocations, shared libraries (.so mmap), and third-party middleware like Wwise. These memory sources are harder to identify because they are not directly tied to traditional game assets. This article explains the most common causes of non-resource memory growth, how to detect memory leaks and abnormal memory residency, and how GOT Online helps developers analyze memory behavior across Lua, Mono, native code, and audio systems.
About GameOptim GameOptim helps Unity developers identify memory issues, rendering bottlenecks, and performance regressions through automated profiling and cloud based performance analysis. Explore more: 🌐 Website: www.gameoptim.com https://www.gameoptim.com/?fopt=blog 📘 Blog: www.gameoptim.com/blog/ https://www.gameoptim.com/blog/ 💼 LinkedIn: www.linkedin.com/company/gameoptim/ https://www.linkedin.com/company/gameoptim/ 🎥 YouTube: GO.PerformanceLab https://www.youtube.com/@GO.PerformanceLab 💬 Discord: GameOptim https://discord.gg/4Jh6hj9gRw ⭐ GitHub: GameOptim https://github.com/GameOptim/unity mobile performance guide 💻 Dev: GameOptim https://dev.to/gameoptim https://uwa overseas images.oss us east 1.aliyuncs.com/Blog/HeadImage/OptimizationGuide13%280%29.jpg Core Concepts Understanding Non Resource Memory in Unity After resource memory is optimized, excessive memory consumption often originates from runtime systems rather than game assets themselves. The primary areas discussed in this article include: Lua Memory Lua Garbage Collection GC Lua References to Mono Objects Lua Configuration Tables Native Heap Memory .so mmap Memory Wwise Audio Memory These memory categories frequently appear as the gap between Reserved Total and PSS Total and can become major contributors to crashes, memory leaks, and long term memory growth. Lua Memory and Garbage Collection Lua memory is primarily allocated through: Tables Functions Userdata Runtime script objects Lua uses a mark and sweep garbage collection mechanism with incremental collection introduced in Lua 5.1. Memory growth is influenced by: Allocation frequency GC execution frequency LUA GCSETPAUSE settings LUA GCSETSTEPMUL settings Excessively infrequent GC can cause large memory peaks, while overly aggressive GC increases CPU overhead. Lua to Mono Reference Management Lua frequently interacts with Unity C objects through wrapper layers. To prevent Unity objects from being collected prematurely, references are stored inside C containers. However, if these references are not released correctly: Destroyed Unity objects remain referenced Mono Heap memory continues growing Long term memory leaks occur Monitoring destroyed objects that are still referenced is an important part of leak detection. Native Heap and Untracked Memory Not all memory can be analyzed through Unity Memory Profiler. Native Heap memory may originate from: IL2CPP Unity engine subsystems Third party SDKs Native plugins Rendering systems When Native Heap continues increasing, tools such as Perfetto and heapprofd become essential for identifying allocation sources and potential leaks. Shared Library .so mmap Memory Android applications map shared libraries into memory. Typical contributors include: libunity.so libil2cpp.so Lua libraries SDK libraries Third party plugin libraries Excessive .so memory reduces available runtime memory and increases OOM risk on low memory devices. Wwise Audio Runtime Memory Wwise maintains its own memory system outside Unity's Mono and Native memory tracking. Major memory categories include: Metadata memory Media memory Runtime playback memory Streaming and I/O memory Incorrect Bank management or loading strategies can cause significant memory residency. Best Practices Lua Memory Optimization Monitor Lua memory growth trends throughout long duration tests. Investigate abnormal increases in Table, Function, and Userdata counts. Adjust GC frequency when memory peaks become excessive. Use source code testing whenever possible for accurate profiling. Prevent Lua Induced Mono Memory Leaks Regularly inspect Destroyed Object Count. Release Lua references promptly when objects are no longer needed. Combine Lua Mode and Mono Mode analysis to verify leak sources. Avoid retaining references to destroyed scene objects. Optimize Lua Configuration Tables Remove duplicate values. Store default values through metatables. Replace repeated strings with IDs. Deduplicate repeated sub tables and arrays. Keep configuration data read only. Analyze Native Heap Memory Use Perfetto for native allocation tracking. Focus on continuously growing allocations. Investigate IL2CPP, rendering modules, audio systems, and native plugins. Verify whether long term allocations are required or leaking. Reduce .so mmap Memory Remove unused SDKs and libraries. Retain only required ABI architectures. Enable code stripping. Remove unused Unity modules. Audit Lua and wrapper generated native code. Optimize Wwise Memory Usage Split SoundBanks by scene and usage. Avoid loading large banks globally. Match loading modes to audio type. Stream long audio assets. Load frequently reused short sounds into memory. Tune platform specific memory pool settings. Key Takeaways Resource memory is only part of total application memory. Lua memory growth often originates from GC configuration and object retention. Lua to Mono references are a common source of hidden memory leaks. Native Heap issues require dedicated profiling tools such as Perfetto. Excessive .so mmap memory can significantly increase OOM risk. Wwise memory should be managed through proper Bank architecture and loading strategies. Long duration testing is critical for exposing memory residency and leak issues. FAQ Why is PSS Total much higher than Reserved Total? The difference often comes from Lua memory, Native Heap allocations, shared libraries, third party SDKs, and middleware memory that are not directly included in Unity resource memory statistics. How can I identify Lua memory leaks? Monitor long term memory growth, analyze Table and Userdata counts, and inspect Lua allocation data in GOT Online Lua Mode. Why do destroyed Unity objects still consume memory? Lua may still hold references to those objects through wrapper layers, preventing Mono memory from being released. When should Perfetto be used instead of Unity Memory Profiler? When investigating Native Heap growth, native plugins, IL2CPP memory issues, or Untracked Memory. What causes excessive .so mmap memory? Large shared libraries, redundant SDKs, multiple ABI builds, and excessive generated native code. How can Wwise memory usage be reduced? Optimize SoundBank granularity, choose appropriate loading modes, unload unused Banks, and tune runtime memory settings based on device tier. Continue reading the series 1. Why Do Mobile Games Crash, Lag, or Overheat? A Unified Framework for CPU, GPU, and Memory Optimization in Unity https://www.gameoptim.com/blog/post/OptimizationGuide1 2. How to Control Runtime Memory in Unity Mobile Games: PSS Standards, Memory Profiler Analysis, and Optimization Workflows https://www.gameoptim.com/blog/post/OptimizationGuide2 3. Common Resource Memory Issues in Unity Mobile Games https://www.gameoptim.com/blog/post/OptimizationGuide3 4. Why Is Texture Memory So High in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide4 5. How Do Vertex Count, Vertex Attributes, and Read/Write Settings Affect Mesh Performance in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide5 6. How Can You Reduce Animation Memory Usage and Runtime Overhead in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide6 7. How Can You Reduce Audio Memory Usage and Playback Overhead in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide7 8. How Can You Reduce Material Count and Avoid Material Related Performance Waste in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide8 9. How Can You Reduce Render Texture Memory Usage and Rendering Overhead in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide9 10. What Causes Excessive Shader Memory Usage and Variant Explosion in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide10 11. Why Do Font and Particle System Resources Consume Excessive Memory in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide11 12. Why Does Mono Heap Memory Keep Growing and Trigger GC Spikes in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide12 14. What Defines a CPU Bottleneck in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide14 15. Unity Rendering CPU Optimization: Why Is Rendering Time So High? https://www.gameoptim.com/blog/post/OptimizationGuide15 16. What Causes UI Performance Bottlenecks in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide16 17. Is Unity Physics Wasting CPU Time on Mobile? How to Detect and Reduce Hidden Physics Overhead https://www.gameoptim.com/blog/post/OptimizationGuide17 18. Why Is Unity Animation Taking Too Much CPU on Mobile? https://www.gameoptim.com/blog/post/OptimizationGuide18 19. How to Reduce Particle System CPU Spikes and Runtime Overhead in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide19 20. How Can I Reduce Unity Loading Time and Avoid Runtime Stutters? https://www.gameoptim.com/blog/post/OptimizationGuide20 21. How Can I Optimize Unity Logic Code, Lua, and Hotfix Runtime Performance? https://www.gameoptim.com/blog/post/OptimizationGuide21 22. How Do I Identify GPU Bottlenecks in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide22 23. How can developers accurately determine whether a Unity mobile game is GPU Bound using GPU Clocks? https://www.gameoptim.com/blog/post/OptimizationGuide23 24. How can developers identify and optimize GPU vertex stage bottlenecks in Unity mobile games? https://www.gameoptim.com/blog/post/OptimizationGuide24 25. How can developers identify and reduce GPU fragment stage bottlenecks in Unity mobile games? https://www.gameoptim.com/blog/post/OptimizationGuide25 26. How to Reduce Shader Complexity in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide26 27. How to Optimize Post processing in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide27 28. How to Reduce GPU Bandwidth in Unity Mobile Games? https://www.gameoptim.com/blog/post/OptimizationGuide28 29. Why Does My Unity Mobile Game Overheat, Drain Battery Fast, and Drop FPS After a While? https://www.gameoptim.com/blog/post/OptimizationGuide29