Cause and mechanism
A RenderTexture is a GPU image that receives camera output or other rendering. When creating these repeatedly, assign ownership and a clear end of use. Release frees the GPU allocation; Destroy destroys the Unity object and can also release its GPU resources. Check cleanup against how that particular texture was obtained.
Check and correct the setup
- Detach owned textures from camera/UI, release their backing storage, and destroy unneeded Unity objects.
Release / Dispose - Return GetTemporary textures with ReleaseTemporary. Do not apply owned-object destruction to assets or borrowed textures.
Release / Dispose - Match cleanup to the API: RTHandle.Release and buffer Dispose where appropriate. Clean up superseded size-dependent resources.
Release / Dispose
Limits and verification
Release leaves the RenderTexture object alive and its storage can be recreated. Remove users and verify memory stabilizes over repeated open/close cycles.
A focused diagnostic setup
As a diagnostic example, repeat opening/closing about ten times at fixed resolution. The count is a way to reveal growth, not a pass threshold.
Test in this order
- After warmup record texture counts, dimensions and references.
Release / Dispose - Repeat measurements and distinguish owned objects from temporary pools and internal textures.
Release / Dispose - Test resize, interrupted close and reopen against old references and cleanup.
Release / Dispose
Interpret the result
Process memory not dropping immediately does not prove a leak. Look for unneeded owned textures growing across cycles; pool retention is a separate case.