Reproduction Steps
Context
My brother (mrmudman) and I are in the process of creating a mega mall shopping / avatar dress up game which will contain a large amount of humanoid mannequins, each displaying both 2D and 3D clothing and accessories.
There are multiple ways of reproducing this issue, listed below.
Using a decal
- Create a baseplate game in studio
- Insert a new decal instance
- Enter play mode
- Load a unique texture into this decal (a texture that has not been previously used within the place)
- Remove the texture from the decal, leaving the decal instance
Changing avatar look / clothing
- Join a game using an avatar that has clothing
- Change the clothing worn on the avatar through the site customization tools.
- Reset character to load this new appearance
- Every unique combination of clothing items worn adds approx 1mB - 2mB of memory usage
Observing another player performing this sequence of actions will also cause this issue
Using a MeshPart with texture (both embedded & non-embedded)
- Create a baseplate game in studio
- Insert a meshpart with a texture into this place
- Enter play mode
- Remove the meshpart & associated texture from the client
These are only a few examples of how to reproduce this memory leak, there are a multitude of other methods to also reproduce this. Everything that has a texture will cause this issue.
Expected Behavior
When a texture is no longer in use on the client (referred to by any texture instances or in any other way), it should be removed from the client’s memory.
Actual Behavior
The texture stays loaded within the client’s memory, even when no longer in use on both the client AND the server. This means that when a new texture is sent to the client, it will permanently be added to the client’s memory. Without any means to remove this memory usage, the client’s memory will rapidly increase as more textures are sent to it, leading to crashes on low end devices.
Memory usage graph - texture was inserted then removed 5 seconds later
Memory has not decreased even though texture was removed
Texture in decal & using GraphicsTexture memory
Texture removed from decal & still using GraphicsTexture memory
This memory leak imposes a hard limit to how many textures can be implemented into into a place in total.
Every game that allows users to utilize their avatar’s appearance is susceptible to this memory leak.
Every game that uses textures temporarily is susceptible to this memory leak
Further related issues discovered
Using the client to join a new game while not closing the executable does not unload the textures used by the previous game from memory
Here is the same place, with the 1st screenshot showing the game opened directly from the website and the 2nd screenshot showing a memory increase after transferring from a different game without closing the executable
Issue Area: Engine
Issue Type: Performance
Impact: High
Frequency: Constantly
Date Last Experienced: 2022-08-27 00:08:00 (+10:00)
A private message is associated with this bug report