LoliKingdom / LoliASM

The lolis are now preparing to bytecode manipulate your game.
GNU Lesser General Public License v2.1
104 stars 22 forks source link

Revamp releaseSpriteFramesCache #168

Closed embeddedt closed 1 year ago

embeddedt commented 1 year ago

This optimization now applies only to TextureAtlasSprite (and FoamFix's copy of the class). Data is now unloaded for all sprites (including animated ones) at startup and is reloaded as needed. Once it has been reloaded, it will remain loaded until it has not been referenced for 20 client ticks, after which it unloads again.

The idea is to take advantage of onDemandAnimatedTextures and not need to keep animated texture data in memory either except for visible animated textures. This can save at least 80MB of memory in larger packs.

This implementation also requires no special casing to work correctly with Tinkers Construct and FoamFix, as it specifically targets the vanilla texture sprite class only (for maximum compatibility).

Would appreciate if someone could give this a go in a larger pack as I have only done testing with a couple mods.