In this lesson, you will learn how to identify memory-heavy textures and apply targeted compression settings to shrink your game's RAM footprint.
The Cost of Raw Textures
Textures are often the single largest contributor to a build's memory usage. When you import an image, Unity defaults to high-quality settings that can consume massive amounts of VRAM. A 2048x2048 texture, when uncompressed (RGBA 32-bit), occupies 16MB of memory. If you have 50 of these, you’ve already dedicated 800MB just to textures, leaving very little headroom for the rest of your game logic.
Identifying the Culprits
To find oversized assets, use the Memory Profiler package. By capturing a snapshot and filtering by Texture2D, you can sort assets by "Size." Look for textures where the "GPU Size" is significantly higher than expected for their visual importance. Often, you will find 4K textures applied to small props that would look identical at 512x512 resolution.
Optimizing via Import Settings
Once you identify a bloated texture, select it in the Project window and head to the Inspector. Adjust these three pillars to slash memory usage:
- Max Size: Reduce this to the lowest resolution that still looks acceptable in-game. Going from 2048 to 1024 reduces the memory footprint by 4x.
- Compression Format: Change this based on your target platform. For Android/iOS, use
ASTC(e.g.,ASTC 6x6or8x8provides a great balance of quality and compression). On desktop, useDXT(BC7 for high-quality, BC1/BC3 for standard). - Generate Mip Maps: While these improve rendering performance and reduce aliasing, they increase memory usage by about 33%. If a texture is only used on a UI element or a static background, disable
Generate Mip Mapsto save that 33%.
// Example: Programmatically checking a texture's memory footprint
// Only use this in Editor scripts for build-time analysis
long bytes = Profiler.GetRuntimeMemorySizeLong(myTexture);
Debug.Log($"Texture {myTexture.name} uses {bytes / 1024f / 1024f:F2} MB");
By aggressively adjusting Max Size and choosing platform-specific compression, you keep your memory budget lean without sacrificing the visual integrity of your project.
Key Takeaway: Prioritize the smallest resolution and most efficient compression format per texture type, disabling Mip Maps for non-3D elements to reclaim significant VRAM.