-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] #529 - 앱 메모리 최적화(솝탬프, 콕찌르기, 마이페이지, 홈캘린더) #532
Conversation
- menuItems 클로저에서 self 강한참조 -> [weak self]로 변경 - UICollectionViewCompositionalLayout에서 self 강한 참조 -> [weak self]로 변경
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아요~!!! 네비바랑 화면전환의 책임분리가 제대로 되어있지 않은 부분들 리팩하면서 한꺼번에 고쳐보아용 🚀
@@ -227,27 +227,27 @@ extension AppMyPageVC { | |||
|
|||
// TODO: - (@승호): 적절히 객체에 위임하기 | |||
private func addTabGestureOnListItems() { | |||
self.servicePolicySectionGroup.addTapGestureRecognizer { | |||
self.onPolicyItemTap?() | |||
self.servicePolicySectionGroup.addTapGestureRecognizer { [weak self] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어쩐지 마이페이지만 진입하면 앱 메모리가 증가한다 했었는데~!
@@ -57,21 +57,21 @@ final class PokeCoordinator: DefaultCoordinator { | |||
|
|||
pokeMain.vm.onPokeButtonTapped = { [weak self] userModel in | |||
guard let self else { return .empty() } | |||
return self.showMessageBottomSheet(userModel: userModel, on: pokeMain.vc.viewController) | |||
return self.showMessageBottomSheet(userModel: userModel, on: self.rootController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
같은 뷰를 갖고 있었던 솝마디도 똑같은 부분에서 누수가 있었어유. 굿굿
🌴 PR 요약
앱 전체적으로 발생하고 있는 메모리 누수 최적화를 진행했습니다.
🌱 작업한 브랜치
🌱 PR Point
문제 발생
#528 이슈를 해결하던 도중, 솝탬프 진입 횟수만큼
MissionListRepository
가 메모리에 남아있는 현상을 발견했습니다.메모리 그래프를 살펴보니,
MissionListVC
가deinit
되지 않아ViewModel -> UseCase -> Repository
까지 모두 메모리에 남아 누수가 발생하고 있었습니다.앱의 다른 부분도 확인해보았는데 4개의 화면에서 동일한 누수가 발생하고 있었습니다. 첨부한 이미지는 마이페이지, 홈캘린더, 콕찌르기, 솝탬프를 각각 5회 진입 한 후 메모리 사용량입니다.

각 플로우의 진입 횟수만큼 객체가 쌓이는 것을 확인할 수 있었습니다.
문제 해결
1️⃣ HomeCalendarDetail
self
를 직접 캡처하고 있던 클로저 1곳을[weak self]
로 수정했습니다.2️⃣ MyPage

self
를[weak self]
로 수정하여 순환 참조를 끊었습니다.3️⃣ MissionList

UICollectionViewCompositionalLayout
에서 누수 원인을 찾을 수 있었고, 관련 코드를 찾아 수정했습니다.4️⃣ PokeMainVC


[weak self]
로 캡처하도록 수정한 뒤,deinit
이 정상적으로 동작하는 것을 확인했습니다.결과
📌 참고 사항
MissionListVC
의space
간격을 4로 수정했습니다.OPNavigationBar
에서도 VC를 주입받고 있어서 VC를 제거하려고 했으나, 너무 많은 플로우에서 해당navigationBar
를 사용하고 있고 메모리 누수와 직접적인 연관이 없어 수정하지 않았습니다. ([Refactor] 화면 전환 방식 리팩토링 (Coordinator, Router) #515 에서 함께 진행해보아요)VC에서 클로저 호출 -> Coordinator에서 클로저 구현
방식으로 화면전환을 하고 있는 부분이 있는데,View는 UI만, ViewModel은 상태 관리, Coordinator가 화면전환의 역할을 갖고 있는만큼
VC -> VM -> Coordinator흐름
으로 리팩토링 하는 걸 제안드립니다 !📮 관련 이슈