OpenRA/OpenRA — pull request #5712 by RoosterDragon (2014-06-22 15:21:11+00:00)
Title: Release sheet buffers

Sheets carry a managed buffer of data that allows updates to be made without having to constantly fetch and set data to the texture memory of the video card. This is useful for things like SheetBuilder which make small progressive changes to sheets.

However these buffers are often large and are kept alive because sheets are referenced by the sprites that use them. If this buffer is explicitly null'ed when it is no longer needed then the GC can reclaim it. Sometimes a buffer need not even be created because the object using the sheet only works on the texture directly anyway.

In practise, this reduced memory consumed by such buffers from ~165 MiB to ~112 MiB (at the start of a new RA skirmish mission).

In detail, at the start of the RA skirmish mission buffers still allocated were created by:
MapCache (16m)
SpriteFont (16m)
VoxelLoader (16m)
SequenceCache * 4 (16m) (one per tileset)

112 MiB.

Buffers that had been released:
SeqeunceCache * 2 (16m) (I think two tilesets overflowed and needed new textures so these ones were able to be freed)
CursorProvider (16m)
Theatre (1024k)
Something From File (2048k)
Something From File (1024k)
Something From File (512k)
Something From File (256k)
Something From File (64k)
RadarWidget * 4 (16k)

53 MiB freed up compared to before where these buffers were being kept around despite not being needed.

I didn't bother checking what the stuff loaded by files had come from, I just know it was some files.