When is Sequencer destoryed?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

When is Sequencer destoryed?

Post by VoodooDetective »

I'm still trying to track down a couple memory leaks between levels. It looks like the Sequencers are mostly not destroyed (as far as I can tell?), and as a result the ActiveConversationRecord object sticks around between levels which also forces our character portraits (which are contained in atlases that contain the entire portrait animation set) to stay in memory.

I'm wondering if it's safe to add:

Code: Select all

            s_awakeSequencer = null; 
To:

Code: Select all

        private void FinishSequence()
        {
            m_isPlaying = false;
            if (FinishedSequenceHandler != null) FinishedSequenceHandler();
            if (m_informParticipants) InformParticipants(DialogueSystemMessages.OnSequenceEnd);
            if (m_closeWhenFinished)
            {
                FinishedSequenceHandler = null;
                Close();
            }
            s_awakeSequencer = null; 
        }
In Sequencer. Or would that cause issues? Is there a better way to handle this?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: When is Sequencer destoryed?

Post by Tony Li »

Sequencer is a MonoBehaviour. You'll know it's destroyed when the Sequencer component disappears from the Dialogue Manager GameObject.

When a conversation starts, it adds a Sequencer component to the Dialogue Manager. When the conversation ends, it destroys the Sequencer component (with a one second delay for legacy reasons).

Is it possible that the dialogue UI is holding onto the image references? If a dialogue UI's subtitle panel or response menu panel portrait image still points to a character's portrait when the conversation ends and the dialogue UI goes inactive, then that portrait atlas will stay in memory.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: When is Sequencer destoryed?

Post by VoodooDetective »

Ah so I do maintain references, but I clear them at the end of the conversation. I tried making the change I mentioned above, and clearing the static reference seems to have fixed the issue for me.

Will setting s_awakeSequencer to null in FinishSequence be a problem elsewhere, or should I be ok there?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: When is Sequencer destoryed?

Post by Tony Li »

No, that's fine. I'll make the same change in 2.2.25.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: When is Sequencer destoryed?

Post by VoodooDetective »

Oh sweet! Thanks very much!
Post Reply