Figure: Diagnostic workflow: Creation and ownership → Appropriate release path → Measure repeated use
Figure: Diagnostic workflow: Creation and ownership → Appropriate release path → Measure repeated use

Cause and mechanism

A RenderTexture uses GPU image memory. If memory keeps growing when opening and closing a view, track who creates it, who uses it, and when its use ends. Release frees its GPU allocation; Destroy destroys the Unity object and can also free its GPU resources. Choose cleanup appropriate to owned versus temporary render textures.

Check and correct the setup

  1. Detach owned textures from camera/UI, release their backing storage, and destroy unneeded Unity objects.
    Release / Dispose
    Release / Dispose
  2. Return GetTemporary textures with ReleaseTemporary. Do not apply owned-object destruction to assets or borrowed textures.
    Release / Dispose
    Release / Dispose
  3. Match cleanup to the API: RTHandle.Release and buffer Dispose where appropriate. Clean up superseded size-dependent resources.
    Release / Dispose
    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

Assign creation, borrowing and end-of-use ownership for a minimap texture. Cameras/UI reference it while a manager owns it.

Test in this order

  1. Inventory new, temporary-pool, RTHandle and asset acquisition paths.
    Release / Dispose
    Release / Dispose
  2. Detach consumers and release once through the matching owner/API.
    Release / Dispose
    Release / Dispose
  3. Check resize and reopen cycles against creation/release and object counts.
    Release / Dispose
    Release / Dispose

Interpret the result

Distinguish premature shared-resource destruction from retention after use. Extra release calls are not safer. Decide per owner whether to reuse the released object or destroy it.

Related explanations

References