ekazaev / ChatLayout

ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.
MIT License
896 stars 67 forks source link

Example App Views Memory Leak? #72

Closed ElrB closed 6 months ago

ElrB commented 6 months ago

Hi @ekazaev

I hope you are well. Having built my app's chat vc off the example app, I was checking if the chat vc was being deallocated after popping it. The result was yes, chat vc is always deallocated, but I realised some of the chat views remain in memory, cause the memory to always increase when opening the same chat. I have a few pics below from memory graph debugger.

I know it's not a big deal, but can you shed a light on it? Thanks.

I took the screenshot below after entering and dismissing chat view 3 times, which has 4 messages.

Screenshot 2024-05-03 at 8 51 42 PM Screenshot 2024-05-03 at 8 52 06 PM

ekazaev commented 6 months ago

@ElrB Hi

Thank you for the issue.

It technically should not. But example app I mostly use for the experiments, so some memory issues may slip away from me. But the quick look doesnt show any problems.

How I checked it. Replace the setEditNotEdit method with:

    @objc
    private func setEditNotEdit() {
        let viewController = UIViewController()
        viewController.view.backgroundColor = .red
        navigationController?.viewControllers = [viewController]
    }

Start the example app. Hit "edit" button. When the view controller is replaced stop to check the Memory graph. I dont see any issues there. Only singletons are left in memory.

Screenshot 2024-05-07 at 18 19 57

So I would suggest to check your code and find out what is holding those objects in the memory.

ekazaev commented 6 months ago

Closing due to inactivity.