Skip to content

~1 GB of native GPU memory kept after reloading a scene with a RiveWidget (D3D12); never released in batch mode #180

Open

Description

@josehsdsilva

rive-unity 0.4.5, Unity 6000.3.27f2, Windows D3D12 (RTX 3060 Laptop 6 GB); same shape seen on Android (Huawei SNE-LX1).

Repro: a scene with one Canvas + RivePanel + RiveWidget (our HUD .riv). In Play Mode, load that scene 6 times with LoadSceneMode.Single (15 s each), then an empty scene + Resources.UnloadUnusedAssets(). Sample the editor process's dedicated GPU memory.

Interactive editor: load 1 = 1.6 GB, load 2 = 2.7 GB (+1.07 GB), loads 3-6 flat at 2.7 GB; the empty scene + UnloadUnusedAssets + GC.Collect/WaitForPendingFinalizers does not bring it down. Unity's own Profiler.GetAllocatedMemoryForGraphicsDriver stays flat (~950 MB) and no Unity Texture is duplicated, so the extra memory is native.

Batch mode (-batchmode -runTests, with a graphics device): every load keeps ~1.07 GB until VRAM is exhausted; the 7th load crashes (D3D12, 0xC0000409) or hangs (D3D11) in the native bind. We believe RendererCleanupHelper.ReleaseRenderer's DeferredRelease (yield WaitForEndOfFrame) never resumes there. -nographics avoids it.

On a 4 GB Android phone the +0.8 GB after an in-app reboot (scene reload) contributes to low-memory kills.

Checked the release notes up to v0.5.3-canary.127 and did not see this addressed.

Activity

  1. josehsdsilva commented on Nov 11, 2026

    @josehsdsilva
    Author

    Extra data point (same setup, interactive editor, D3D12): between loads the Rive scene is unloaded into an empty runtime scene, Resources.UnloadUnusedAssets() runs, and frames render for 6 s before the next load, so the old and new panels never coexist and the end-of-frame deferred release has had time to run.

    Step Process dedicated GPU
    load 1 1.6 GB
    empty scene, no Rive object alive 1.6 GB
    load 2 2.7 GB (+1.07 GB)
    empty scene 2.7 GB
    loads 3-6 2.7 GB (short peaks, back to 2.7)

    So the memory of a destroyed panel is never returned while the process lives, even with no Rive panel in the scene, and the second panel reserves another ~1 GB that later loads reuse.

  2. damzobridge commented on Nov 12, 2026

    @damzobridge
    Contributor

    Thanks for the detailed issue report @josehsdsilva . Could you try the latest experimental release v0.5.2-exp.9 and confirm whether it addresses the issue on your end? You can use this in the package manager to install it:

    https://github.com/rive-app/rive-unity.git?path=package#v0.5.2-exp.9
    

    We've reworked our resource management on that branch, so this should be fixed there. If not, please let us know.

  3. josehsdsilva commented on Nov 12, 2026

    @josehsdsilva
    Author

    Thanks for the quick turnaround, v0.5.2-exp.9 fixes it on our side.

    Same setup as the report (Unity 6000.3.27f2, Windows 11, RTX 3060 Laptop, D3D12), same probe, dedicated GPU memory of the editor process sampled every 2 s:

    v0.4.5 v0.5.2-exp.9
    Lab scene, 1st load 1603 MB 1605 MB
    2nd–6th load (Single) 2674 MB (+1071), stays 1605 MB every load (brief spike during the swap only)
    Empty scene afterwards 2658 MB 1605 MB
    Batch mode with a GPU device, game scene loaded repeatedly crash/hang on the 7th load 22 loads, flat at ~2.9–3.0 GB, all 22 tests green

    So the per-load growth is gone, and so is the batch-mode exhaustion. One remaining observation, not a blocker for us: the ~1.1 GB pool is kept after the last Rive panel is destroyed (empty scene stays at 1605 MB vs ~520 MB before the first load). Is that expected?

    Also worth noting for others testing: right after switching the package version, the first editor session logs "Rive native plugin is unavailable because the package was updated" and nothing renders until the editor is restarted.

    We'll move to the stable release once it ships. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions