Skip to content

Comments

fix: 클로저 내부에서 cell을 약한 참조로 캡쳐하여 메모리 누수 해결#133

Merged
chanhihi merged 1 commit intodevelopfrom
dev/132-fix-leaks-해결/#132
Apr 2, 2024

Hidden character warning

The head ref may contain hidden characters: "dev/132-fix-leaks-\ud574\uacb0/#132"
Merged

fix: 클로저 내부에서 cell을 약한 참조로 캡쳐하여 메모리 누수 해결#133
chanhihi merged 1 commit intodevelopfrom
dev/132-fix-leaks-해결/#132

Conversation

@noeyiz
Copy link
Collaborator

@noeyiz noeyiz commented Mar 28, 2024

📌 개요

  • Instruments를 통해 발견한 메모리 누수를 해결합니다.

💻 작업 내용

  • BoxListCell, EditFolderCell의 onEdit, onDelete 클로저를 설정해주는 부분에서 cell에 대해 약한 참조를 캡쳐하도록 수정했습니다.
    cell.onDelete = { [weak self, weak cell] in
        guard let self = self, let cell = cell else { return }
        if let currentIndexPath = self.tableView.indexPath(for: cell) {
            self.delegate?.deleteFolder(at: currentIndexPath)
        }
    }
    cell.onEdit = { [weak self, weak cell] in
        guard let self = self, let cell = cell else { return }
        if let currentIndexPath = self.tableView.indexPath(for: cell) {
            self.editFolderName(at: currentIndexPath)
        }
    }
    

Instruments에서 메모리 누수가 나지 않는 모습 !
Screenshot 2024-03-28 at 5 36 22 PM

@noeyiz noeyiz linked an issue Mar 28, 2024 that may be closed by this pull request
@noeyiz noeyiz changed the title 🐛 fix: 클로저 내부에서 self, cell을 약한 참조로 캡쳐하여 메모리 누수 해결 🐛 fix: 클로저 내부에서 cell을 약한 참조로 캡쳐하여 메모리 누수 해결 Mar 28, 2024
@noeyiz noeyiz changed the title 🐛 fix: 클로저 내부에서 cell을 약한 참조로 캡쳐하여 메모리 누수 해결 fix: 클로저 내부에서 cell을 약한 참조로 캡쳐하여 메모리 누수 해결 Mar 28, 2024
Copy link
Member

@chanhihi chanhihi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 끝에 순환참조의 늪에서 빠져나오게 되어서 너무 기쁩니다.

@chanhihi chanhihi merged commit 405995a into develop Apr 2, 2024
@chanhihi chanhihi deleted the dev/132-fix-leaks-해결/#132 branch April 2, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: leaks 해결

2 participants