- Edited
Skeleton Mesh memory leak in Unity
First of all, hello
We use spine & spine-unity in our company nearly for a year, so far, it satisfies our needs and we are happy with the results.
But a problem occured recently in last project.
We use a main character created in spine as a SkeletonAnimation. Since it has many components (like equipments) and we use it nearly every panel of our game, we decided to move it around along the panels. While moving it, we also initialize the SkeletonAnimation for various reasons.
If we initialize the SkeletonAnimation, a Skeleton Mesh memory leak occurs. It builds up on every initialization and if we dont call Resources.UnloadUnusedAssets(); it stays all game. By the way, GC.Collect(); does not free the leak.
Thank you in advance.
-Buğra
Are you on the latest version? This should have been fixed a few months ago. I'll check it out either way.
For what reasons are you calling initialize on the mesh?
You can currently try replacing your project's SpineMesh.cs
with this code: https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/3.6/spine-unity/Assets/spine-unity/Mesh%20Generation/SpineMesh.cs
It might fix it.
It did fix it, this is the first time i see someone posts a script and it solves the problem immediately at first reply. Thank you!
I was using the latest version btw.
Good to know!
Your repro of the leak coming from force-initialization was helpful in tracking down the cause.
I'm still curious about why you needed to call Initialize multiple times though.