Search Unity

2020.2: building using SpriteAtlases leaks Texture2D memory ( >40Gb in our case never released )

Discussion in 'Editor & General Support' started by spacefrog, Dec 16, 2020.

  1. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    I observed this already in 2020.1 , but did not have the time to report it ( and we still stick to 2019.4 ) - But here's the thing:

    Since 2020.1, making a build of a project making heavy use of spriteatlases (new version) loads all the Texture2D into memory and never frees it. In our case ( huge spriteatlases ) after the build is finally finished 40GB of editor memory never get freed until restart.
    Using the great Heap Explorer by Peter77 to create an editor snapshot and analyze it, i see the whopping 42Gb of Texture2D (spritesheets ) still stuck in memory, referenced by their sprite definitions
    This will never get freed until an editor restart!

    As said, this started with Unity 2020.1, and is probably a regression from Unity 2019 bug the i reported for 2019 ( for which it got fixed ). But seemingly bug crept back in with the 2020.1 release and is stil rampant in the 2020.2 release. Note: will create a bug report about this as soon as i find time to do

    NFH_afterbuild.jpg