Chat SDK V2 Memory issue iOS | Community
Skip to main content

Chat SDK V2 Memory issue iOS

  • May 18, 2022
  • 12 replies
  • 0 views

Hi,

We are using Chat SDK V2 and we see some memory issues. We are presenting the chat as modal and on dismiss we could see instances of `ChatSDK` being retained. The view is getting destroyed properly.

[Strange I am unable to upload any images from the memory graph] so posting some of the contents... as you can see, if I go to the screen around 10 times, you get those many objects retained.

0. ChatSDK(74)

1. ChatEngineStarter (9)

2. ChatFormHandler(9)

3.ZDKChatEngine(9)

4.ZDKChatFormConfiguration(10)

We are building the UI like this 

    func buildUI() throws -> UIViewController {

        // Name for Bot messages

        let messagingConfiguration = MessagingConfiguration()

        messagingConfiguration.name = “Bot"

        let formConfiguration = ChatFormConfiguration(name: .required, email: .required, phoneNumber: .required, department: .required)

        let chatConfiguration = ChatConfiguration()

        chatConfiguration.isAgentAvailabilityEnabled = false

        chatConfiguration.isPreChatFormEnabled = true

        chatConfiguration.chatMenuActions = [.emailTranscript, .endChat]

        chatConfiguration.preChatFormConfiguration = formConfiguration

        

        // Build view controller

        let chatEngine = try ChatEngine.engine()

        return try Messaging.instance.buildUI(engines: [chatEngine], configs: [messagingConfiguration, chatConfiguration])

    }

12 replies

Eric27
  • May 20, 2022
Hey Anoop,

Dismissal of the modal won't cut the session, this would defeat the purpose of push notifications and the like. We talk about the conditions of when the session will terminate here.
 
Hope this helps

  • Author
  • May 20, 2022

I understand that but my concern is that if I open the modal multiple times why the allocation is increasing even if it is only one session, sdk should ideally reuse the stuffs from an existed session right. For example if I close and open modal 9 times with in the same session I end up seeing 9 chat engines which is alive in the memory why is that so? or am I wrong.

ZDKChatEngine(9) 


Eric27
  • May 20, 2022
Hey Anoop,

My assumption on why this is happening is because you're engaging the view from outside the navigation stack. When doing this the app wouldn't have a way of checking if there is an engine running as it's outside the navigation controller. I'd attempt modifying your code to use the navigation controller like in our example and see if that solves your issue. 

  • Author
  • May 23, 2022

Okay , I tried that now using the existing navigationcontroller and result is the same.


Eric27
  • May 23, 2022
Hey Anoop,

I haven't been able to replicate this on my side. Would you try using one of our sample applications and let me know if you encounter this issue?

  • Author
  • May 23, 2022

Okies which one corresponds to that ? is it this https://github.com/zendesk/ios_sdk_demo_apps/tree/master/ChatSDKSamples ?


  • Author
  • May 24, 2022

Hi @eric27,

I have created a sample app where you can see the issue. Whats the best way to share it with you?


Eric27
  • May 25, 2022
Hey Anoop,

Sorry I missed your message, mind if I move this into a ticket so that you can share the sample app with me? 

Thanks!

  • Author
  • May 25, 2022

Hi @eric27,

Yes that would be fine and let me know the right place to upload.

-anoop


Eric27
  • May 25, 2022
Hey Anoop,

I just opened up a ticket on your behalf, I've also included instructions in that on how best to send me the application.

Thanks!

  • Author
  • May 25, 2022

Hi @eric27

Added the source code to the ticket itself.

-anoop


Eric27
  • May 26, 2022
Sounds good Anoop, I've taken a look and responded back. I'll continue engaging via that ticket from here on. 
 
Thanks!