Memory GC Alloc Problem

Forums 💬 Slate Sequencer ⚙️ Support Memory GC Alloc Problem

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #21083
    kunzhutsai
    Participant

      Hello! I have some GC Alloc problem
      Thank You
      ————————————
      My cutscene version is 1.4.0.

      My problem is when I play cutscene that the GC is too high.
      Because I want to reduce GC.collect’s frequency. It may cause my game lag.
      Do my best, I modify many code.
      As below the picture 1. the profiler show GC Alloc 5.7KB
      Using the profiler trace which functions make GC high.
      As below the picture 2.
      I find the key point.

      In ActionClip Update using UpdateAnimParams(time, previousTime);
      In UpdateAnimParams function using SetEvaluatedValues(animatedParametersTarget, time);
      In SetEvaluatedValues function using SetCurrentValue(obj, currentEval);
      In SetCurrentValue function using ResolvedObject(obj);

      the point is transform.GetComponent(declaringType).
      When the cutscene is playing, GetComponent will be called by every frame.
      this cause GC Alloc high.

      I want to fix from myself,but this code is too complex.
      I need your advice with the problem.
      ————————————
      Thank You Very Much!!
      My English isn’t very good, please don’t mind

      #21088
      Gavalakis
      Keymaster

        Hey!

        The piece of code you show there should normally only run once, then the component found is cached (_resolved variable). The only case for this to run more than once, is if you have an animated parameter in some of your ‘Property Tracks’ or ‘Animate Properties’ clips, which points to a component that no longer exists (like for example the component is delete).
        Can you please check your Property Tracks and Animate Properties clips and see if there is indeed any animated parameter that shows like this:
        [attachment file=”MissingAnimateParameterTarget.png”]

        Deleting these parameters that have a missing target, should resolve the allocation caused.

        Let me know.
        Thanks!

        #21087
        kunzhutsai
        Participant

          Thank you for your big favor and reply.

          It really resolves my question.
          But I have another question after deleting these parameters that have a missing target.

          In the ‘AnimatedParameter’ scipt, ‘HasAnyKey’ may may cause the allocation when I used ‘Animate Properties’ clips for changing the object rotation or position.
          In ‘HasAnyKey’, the code just gets the Keyframe arrays length, I don’t know why getting array length will cause the allocation .
          I not sure whether the array problem,so I do some test.

          I use a list to record the curves’s Keyframe[] length when the curves initialized. After the ‘InitializeCurves()’ function.
          My idea is that use once Keyframe[] length when beginning.So after that I can use list to search the keys.
          But it is failed. The object’s position that I wnat to move can’t move correctly. Maybe the list record not correctly.I will test persistently.

          This is just my simple test. The main point is calling ‘HasAnyKey’ may may cause the allocation.
          Do you have any good idea for this situation. I not sure whether this problem just only happened to me.

          Hope you can understand what I say.
          Thank you very much!!

          #21086
          Gavalakis
          Keymaster

            Hello,
            This allocation with HasAnyKey(), has already been fixed in version 1.6.0.
            If you want to continue using version 1.4.0 though, you can fix it simply by replacing the method with this code:

            The difference here, is checking curves[i].length instead of curves[i].keys.Length 🙂
            Cheers!

            #21085
            kunzhutsai
            Participant

              Hello! Gavalakis

              Thank you so much!!

              Thanks for help

              #21084
              Gavalakis
              Keymaster

                You are welcome 🙂
                Glad I could be of help.

              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.