- Modificato
Force initializing Spine in runtime causes memory leaks.
Hi all,
My team and I are using Spine for a commercial project. The way we normally use spine, is with a few gameobjects which are normally pooled. We change the spine skeleton during runtime with Initialize(). However, every time we call it, it causes a memory leak for about 100kb. It persists in memory for the remainder of the play-through, even when scenes are unloaded.
I believe our issue is similar to the issue posted here: http://esotericsoftware.com/forum/Skeleton-Mesh-memory-leak-in-Unity-10431
However, we are using the latest version of spine runtime [3.8], and I think their issue was fixed in a prior update. We are using Unity 2018.4.15f, and we primarily use SkeletonGraphic (UnityUI).
Any help is appreciated.
Thanks!
Sylidar ha scrittoWe change the spine skeleton during runtime with Initialize(). However, every time we call it, it causes a memory leak for about 100kb.
Just to be on the same page: I assume you are assigning a different SkeletonDataAsset
and then calling Initialize()
, right?
Does this also happen in a minimal setup when you only switch between different skeletons and not perform any other game logic, repacking attachments, switching materials, etc?
Did you test that this increase does not happen when you omit changing skeletons (removing the spine API calls and leaving the skeleton untouched, just to make sure)?
Does the memory increase also happen when you perform the switch to the same skeleton (and not to a different SkeletonDataAsset
)?
Where exactly did you see the 100kb increase in memory usage? I assume you saw that in the Unity profiler window - if so, which line of the graph showed the 100kb spike or where did you see the 100kb value?
Just to be on the same page: I assume you are assigning a different
SkeletonDataAsset
and then callingInitialize()
, right?
Yes, we do this to avoid instantiate calls.
Does this also happen in a minimal setup when you only switch between different skeletons and not perform any other game logic, repacking attachments, switching materials, etc?
Did you test that this increase does not happen when you omit changing skeletons (removing the spine API calls and leaving the skeleton untouched, just to make sure)?
Does the memory increase also happen when you perform the switch to the same skeleton (and not to a different
SkeletonDataAsset
)?Where exactly did you see the 100kb increase in memory usage? I assume you saw that in the Unity profiler window - if so, which line of the graph showed the 100kb spike or where did you see the 100kb value?
I just tested it on a minimal scene, and it happens as well. I try just initializing the same SkeletonDataAsset, and it still takes memory. Here is a gif of my test: https://gyazo.com/5f53d981372979c17efa76dd8e427376
Thanks for the additional info and the GIF, we were able to find the source of the issue and just released a fix for the leak.
An updated 3.8 unitypackage is available for download here as usual:
Spine Unity Download
Thanks for reporting!
(Issue ticket url for reference: https://github.com/EsotericSoftware/spine-runtimes/issues/1714)
Thanks a lot for the quick fix!