Massive Textures in Memory

For some reason, my game has a bunch of large textures (all 42.7 mb) with no names, so I’m not sure what their origin is. As far as I know, I name all of the textures I create during runtime, and the largest texture asset in the build is only a few megabytes. Also, the texture has no refcounts.

Thus, I’d like to be able to maybe see what this texture looks like - perhaps that could point me in the right direction. Speaking of that, any tips to how I could investigate this?

I decided to try out the awesome Heap Explorer tool, although this didn’t get me much closer to the solution. However, one very interesting fact is that these massive textures are not unloaded, aka because of “isDontDestroyOnLoad, isManager, or hideFlags”. This is very interesting.

I decided to go through every texture creation in my project, including plugins (All I did was search for “new Texture”, so I could have missed something). Sadly I found nothing - it’s incredibly rare to create new textures during runtime in my project.

And yet. Here they are. They’re being made somewhere! Sadly the references in the Heap Explorer are seemingly random, apparently due to a unity bug, By Design™ of course :^)

Any thoughts?

Sprites and post effects can allocate texture or buffer space at runtime. Probably editor too.

1 Like

42.7mb though? :frowning: Also, this is in build, not editor.

Ah ha. I found it.

I built a tool that loads all textures in memory using Resources.FindObjectsOfTypeAll, sorts them by size, and then saves the top X of them.

Turns out these massive textures consist of duplicate, 2048 x 2048 textures that is an atlas of grass textures, seemingly generated by the terrain. Each of these textures takes up 42.7 mb. That is… clearly absolutely insane. I have no idea how this can even be possible.

I am going to make a post on this issue specifically.