To address the memory leak issue you're experiencing with Spine in Unity on mobile platforms, it's important to ensure that all references to Spine objects, especially those related to SkeletonAnimation
and Timeline
, are properly released. This includes making sure that any Spine-related assets or components are not being referenced elsewhere in your code or by Unity's systems, which could prevent them from being garbage collected.
From the contexts provided, there are a few general recommendations for managing memory with Spine in Unity:
Ensure Proper Destruction: When you destroy a GameObject containing a SkeletonAnimation
component, also consider if there are any other references to Spine objects that need to be manually cleared or destroyed. This might include references held in scripts, event listeners, or other components that could keep the objects in memory.
Update and Cleanup: Although you mentioned using a specific version of Spine (spine-unity-3.8-2020-06-17
), it's worth noting that memory management improvements and bug fixes are made in later versions. While you need to stick with this version, reviewing the Spine Unity Download page for any patches or minor updates compatible with 3.8 could be beneficial.
Manual Cleanup: For explicit control over memory, consider manually nullifying references or using specific cleanup methods provided by Spine or Unity. For instance, calling Resources.UnloadUnusedAssets()
might help in forcing the cleanup of unreferenced assets, though its effectiveness can vary based on what's keeping the assets in memory.
Profiling and Debugging: Continue using Unity's memory profiler to identify what specifically holds references to the float[]
arrays and other Spine-related objects. This can provide clues on where to focus cleanup efforts.
Given the specific nature of memory management and the potential for leaks in complex projects, these steps can help mitigate issues but might not cover all cases. Careful profiling and targeted cleanup based on your project's specifics are essential.