Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug 2D Animation package SpriteSkin memory leak in SpriteSkin:CopyToSpriteSkinData

Discussion in '2D' started by vellar92, Oct 31, 2023.

  1. vellar92

    vellar92

    Joined:
    Oct 2, 2017
    Posts:
    1
    Hello, I am using unity 2022.3.10f. I have installed 2D Animation, Burst and Jobs packages. I have a rigged 2D characters. Batching seem to work fine and performance is great, but from time to time I get a memory leak message in Unity Editor.

    It goes something like "Leak Detected : Persistent allocates 1 individual allocations.". Sometimes it is 1 individual allocations, sometimes it is 30.

    I enabled leak detection with stack trace and traced the problem to the UnityEngine.U2D.Animation.SpriteSkin and the method CopyToSpriteSkinData.

    Here is the full stack

    Code (CSharp):
    1. Found 1 leak(s) from callstack:
    2. #0  (Mono JIT Code) [SpriteSkin.cs:608] UnityEngine.U2D.Animation.SpriteSkin:CopyToSpriteSkinData (UnityEngine.U2D.Animation.SpriteSkinData&,int)
    3. #1  (Mono JIT Code) [SpriteSkinComposite.cs:521] UnityEngine.U2D.Animation.SpriteSkinComposite:LateUpdate ()
    4. #2  (Mono JIT Code) [SpriteSkinUpdateHelper.cs:30] UnityEngine.U2D.Animation.SpriteSkinUpdateHelper:LateUpdate ()
    5. #3 mono_jit_runtime_invoke
    6. #4 do_runtime_invoke
    7. #5 mono_runtime_invoke
    8. #6 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
    9. #7 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
    10. #8 MonoBehaviour::CallMethodIfAvailable(int)
    11. #9 MonoBehaviour::CallUpdateMethod(int)
    12. #10 void BaseBehaviourManager::CommonUpdate<LateBehaviourManager>()
    13. #11 LateBehaviourManager::Update()
    14. #12 InitPlayerLoopCallbacks()::PreLateUpdateScriptRunBehaviourLateUpdateRegistrator::Forward()
    15. #13 ExecutePlayerLoop(NativePlayerLoopSystem*)
    16. #14 ExecutePlayerLoop(NativePlayerLoopSystem*)
    17. #15 PlayerLoop()
    18. #16 EditorPlayerLoop::Execute()
    19. #17 PlayerLoopController::InternalUpdateScene(bool, bool)
    20. #18 ???
    21. #19 ???
    Can someone give further information about this leak? Is there a way to fix the problem?
     
  2. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    90
    I have SpriteSkin memory leaks too.

    Found 14 leak(s) from callstack:
    0x000001a709a73c73 (Mono JIT Code) Unity.Collections.NativeArray1<int>:Allocate (int,Unity.Collections.Allocator,Unity.Collections.NativeArray1<int>&)
    0x000001a709a738c3 (Mono JIT Code) Unity.Collections.NativeArray`1<int>:.ctor (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions)
    0x000001a709a6eab3 (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkin:CacheBoneTransformIds (bool) (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkin.cs:327)
    0x000001a709b6682b (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkin:CopyToSpriteSkinData (UnityEngine.U2D.Animation.SpriteSkinData&,int) (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkin.cs:607)
    0x000001a709b664db (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkinComposite:CopyToSpriteSkinData (int) (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkinComposite.cs:388)
    0x000001a709b58f9b (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkinComposite:BatchRemoveSpriteSkins () (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkinComposite.cs:680)
    0x000001a70b435e5b (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkinComposite:LateUpdate () (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkinComposite.cs:520)
    0x000001a70b430263 (Mono JIT Code) UnityEngine.U2D.Animation.SpriteSkinUpdateHelper:LateUpdate () (at ./Library/PackageCache/com.unity.2d.animation@9.0.3/Runtime/SpriteSkinUpdateHelper.cs:29)
    0x000001a7092f4c78 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_voidthis (object,intptr,intptr,intptr)
    0x00007ffdd4c5e084 (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
    0x00007ffdd4b9eb84 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3066)
    0x00007ffdd4b9ed1c (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3113)
    0x00007ff7a72b0b14 (Unity) scripting_method_invoke
    0x00007ff7a728f794 (Unity) ScriptingInvocation::Invoke
    0x00007ff7a7276db4 (Unity) MonoBehaviour::CallMethodIfAvailable
    0x00007ff7a7276eda (Unity) MonoBehaviour::CallUpdateMethod
    0x00007ff7a6d1219b (Unity) BaseBehaviourManager::CommonUpdate<LateBehaviourManager>
    0x00007ff7a6d1981a (Unity) LateBehaviourManager::Update
    0x00007ff7a6f493ad (Unity) InitPlayerLoopCallbacks'::2'::preLateUpdateScriptRunBehaviourLateUpdateRegistrator::Forward
     
  3. DmitrySannikov

    DmitrySannikov

    Joined:
    Nov 4, 2014
    Posts:
    1
    I am getting the same message, is there any solution or thoughts on this?
     
  4. SEVEN7HeavenFoxmail

    SEVEN7HeavenFoxmail

    Joined:
    Oct 21, 2019
    Posts:
    2


    Unity 2023.3.15f. Got the same leak information.
     
  5. timzydee

    timzydee

    Joined:
    Mar 18, 2013
    Posts:
    10
    Same for me.
     
  6. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    216
    Thank you for reporting this. It's a known issue and will be fixed in the next release of the 2D Animation package.
    For Unity 22.3 stream it will be 9.1.1 and for Unity 23 10.1.2.