You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi, our app dynamically loads glb files from url. The code is attached below.
When we destroy our gameobjects, we call GltfAsset..Dispose() and even ClearScenes() in OnDestroy(), but the memory seems not fully released and keeps being eaten up as we load and destroy more of them.
We are using Unity 2022.1.10f1 + URP 13.1.8, building to WebGL, testing with Chrome.
I was wondering if we missed something or there is a bug causing memory leak.
Files
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GLTFast;
public class TestGltf : MonoBehaviour
{
GltfAsset gltfAsset;
public string url = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF/Duck.gltf";
void Start()
{
}
void OnDestroy()
{
if (gltfAsset != null)
{
gltfAsset.ClearScenes();
gltfAsset.Dispose();
}
}
async void Load()
{
gltfAsset = gameObject.AddComponent<GltfAsset>();
gltfAsset.LoadOnStartup = false;
var success = await gltfAsset.Load(url);
if (success)
{
if (!gltfAsset.CurrentSceneId.HasValue && gltfAsset.SceneCount > 0)
{
await gltfAsset.InstantiateScene(0);
}
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.L))
{
Load();
}
}
}
To Reproduce
Steps to reproduce the behavior:
Attach the script to a gameobject and make it a prefab
Instantiate the prefab to scene
Call Load()
Destroy the gameobject
Repeat 2-4. The memory will be eaten up gradually.
Expected behavior
Memory gets fully released after calling Dispose()
Desktop (please complete the following information):
glTFast version: 5.0.0
Unity 2022.1.10f1
Render Pipeline and version: URP 13.1.8
Platform: WebGL
The text was updated successfully, but these errors were encountered:
Hi, unfortunately I haven't solved it. I didn't look closely in whether there's a different behaviour between loading .gltf and .glb. But they both produce the memory issue for me.
Describe the bug
Hi, our app dynamically loads glb files from url. The code is attached below.
When we destroy our gameobjects, we call GltfAsset..Dispose() and even ClearScenes() in OnDestroy(), but the memory seems not fully released and keeps being eaten up as we load and destroy more of them.
We are using Unity 2022.1.10f1 + URP 13.1.8, building to WebGL, testing with Chrome.
I was wondering if we missed something or there is a bug causing memory leak.
Files
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Memory gets fully released after calling Dispose()
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: